You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/01/07 15:44:47 UTC

[GitHub] [pulsar] codelipenghui opened a new issue #13671: Producer semaphore permit release issue

codelipenghui opened a new issue #13671:
URL: https://github.com/apache/pulsar/issues/13671


   **Describe the bug**
   
   ```
   23:41:11.360 [pulsar-client-io-1-1:org.apache.pulsar.client.impl.ProducerImpl@271] ERROR org.apache.pulsar.client.impl.ProducerImpl - Semaphore permit release count request greater then availablePermits : availablePermits=350, releaseCountRequest=380
   ```
   
   **To Reproduce**
   
   Run the following test.
   
   ```java
   package io.streamnative.test;
   
   import org.apache.pulsar.client.api.Consumer;
   import org.apache.pulsar.client.api.Message;
   import org.apache.pulsar.client.api.Producer;
   import org.apache.pulsar.client.api.PulsarClient;
   import org.apache.pulsar.client.api.PulsarClientException;
   import org.apache.pulsar.client.api.Schema;
   import org.apache.pulsar.client.api.SubscriptionInitialPosition;
   import org.apache.pulsar.client.api.SubscriptionType;
   import org.apache.pulsar.client.api.transaction.Transaction;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   
   import java.util.concurrent.CompletableFuture;
   import java.util.concurrent.CountDownLatch;
   import java.util.concurrent.TimeUnit;
   
   public class TransactionTest {
       private static final Logger log = LoggerFactory.getLogger(TransactionTest.class);
       public static void main(String[] args) throws PulsarClientException, InterruptedException {
           final String sourceTopic = "s_topic";
           final String targetTopic = "t_topic";
           PulsarClient client = PulsarClient.builder()
                   .serviceUrl("pulsar://127.0.0.1:6650")
                   .enableTransaction(true)
                   .build();
           Producer<String> producer = client.newProducer(Schema.STRING)
                   .topic(targetTopic)
                   .blockIfQueueFull(true)
                   .sendTimeout(0, TimeUnit.SECONDS)
                   .create();
           Consumer<String> consumer = client.newConsumer(Schema.STRING)
                   .topic(sourceTopic)
                   .subscriptionName("sub")
                   .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                   .subscriptionType(SubscriptionType.Shared)
                   .subscribe();
   
           final int totalTransactions = 100000;
           CountDownLatch latch = new CountDownLatch(totalTransactions);
   
           log.info("Prepare data!");
   
           Producer<String> sourceProducer = client.newProducer(Schema.STRING)
                   .topic(sourceTopic)
                   .sendTimeout(0, TimeUnit.SECONDS)
                   .blockIfQueueFull(true)
                   .create();
   
           for (int i = 0; i < totalTransactions; i++) {
               sourceProducer.newMessage().value(i + "").sendAsync();
           }
           sourceProducer.flush();
   
           log.info("Test started!");
           new Thread(() -> {
               for (int i = 0; i < totalTransactions; i++) {
                   try {
                       Message<String> msg = consumer.receive();
                       log.debug("Received message!");
                       CompletableFuture<Transaction> txn = client.newTransaction().build();
                       txn.thenComposeAsync(transaction -> {
                           log.debug("Transaction opened!");
                               return producer.newMessage(transaction).value(msg.getValue()).sendAsync()
                                   .thenComposeAsync(messageId -> {
                                       return consumer.acknowledgeAsync(msg.getMessageId(), transaction);
                           }).thenAcceptAsync(__ -> {
                               transaction.commit().thenRun(() -> {
                                   log.debug("Transaction committed!");
                                   latch.countDown();
                               }).exceptionally(e -> {
                                   latch.countDown();
                                   return null;
                               });
                           }).exceptionally(e -> {
                               transaction.abort().thenRun(() -> {
                                   log.debug("Transaction aborted!");
                                   latch.countDown();
                               }).exceptionally(ex -> {
                                   latch.countDown();
                                   return null;
                               });
                               return null;
                           });
                       });
                   } catch (PulsarClientException e) {
                       e.printStackTrace();
                   }
               }
           }).start();
   
           latch.await();
           log.info("Test Done!");
       }
   }
   
   ```
   
   **Expected behavior**
   No error logs for producer semaphore permit release
   
   **Additional context**
   both master branch and branch-2.9
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] mattisonchao removed a comment on issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
mattisonchao removed a comment on issue #13671:
URL: https://github.com/apache/pulsar/issues/13671#issuecomment-1007846643


   Could i work on it ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] mattisonchao commented on issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on issue #13671:
URL: https://github.com/apache/pulsar/issues/13671#issuecomment-1007846721


   @codelipenghui 
   
   Could i work on it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] mattisonchao removed a comment on issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
mattisonchao removed a comment on issue #13671:
URL: https://github.com/apache/pulsar/issues/13671#issuecomment-1007846643


   Could i work on it ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] mattisonchao commented on issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on issue #13671:
URL: https://github.com/apache/pulsar/issues/13671#issuecomment-1007846643






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] mattisonchao commented on issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on issue #13671:
URL: https://github.com/apache/pulsar/issues/13671#issuecomment-1007846643


   Could i work on it ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli closed issue #13671: Producer semaphore permit release issue

Posted by GitBox <gi...@apache.org>.
eolivelli closed issue #13671:
URL: https://github.com/apache/pulsar/issues/13671


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org