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/09/07 06:42:06 UTC

[GitHub] [pulsar] massakam opened a new pull request, #17503: [bug][cpp] Fix issue where unexpected ack timeout occurred

massakam opened a new pull request, #17503:
URL: https://github.com/apache/pulsar/pull/17503

   ### Motivation
   When we start a consumer like the following and publish multiple messages to a topic, ack timeout occurs even though the messages received are immediately acknowledged. This does not occur with normal topics, only with partitioned topics.
   ```cpp
   ClientConfiguration clientConfig;
   clientConfig.setMessageListenerThreads(1);
   Client client("pulsar://localhost:6650", clientConfig);
   
   ConsumerConfiguration consumerConfig;
   consumerConfig.setConsumerType(ConsumerShared);
   consumerConfig.setUnAckedMessagesTimeoutMs(10000);
   consumerConfig.setMessageListener([](Consumer con, const Message& msg) {
       cout << "Received: " << msg.getDataAsString() << endl;
       con.acknowledge(msg);
       this_thread::sleep_for(chrono::milliseconds(20000));
   });
   
   Consumer consumer;
   client.subscribe("persistent://public/default/pt4", "sub1", consumerConfig, consumer);
   ```
   
   The reason is that the task of executing the message listener function is queued to `listenerExecutor_` immediately after adding the message to `unAckedMessageTrackerPtr_`, but it is not always executed immediately. If it takes a long time to execute each message listener function like the code for reproduction above, it will take a long time for the queued tasks to actually execute, causing an ack timeout. I don't think this is the expected behavior.
   https://github.com/apache/pulsar/blob/0bbc4e1ee32a3b5f07296614a650367dbd99e607/pulsar-client-cpp/lib/MultiTopicsConsumerImpl.cc#L462-L464
   
   ### Modifications
   
   Have `listenerExecutor_` perform adding messages to `unAckedMessageTrackerPtr_`. In this way, the message listener function will always be executed immediately after adding a message to `unAckedMessageTrackerPtr_`, preventing unexpected ack timeouts.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   ### Documentation
   
   - [ ] `doc-not-needed`


-- 
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] BewareMyPower merged pull request #17503: [bug][cpp] Fix issue where unexpected ack timeout occurred

Posted by GitBox <gi...@apache.org>.
BewareMyPower merged PR #17503:
URL: https://github.com/apache/pulsar/pull/17503


-- 
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] github-actions[bot] commented on pull request #17503: [bug][cpp] Fix issue where unexpected ack timeout occurred

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #17503:
URL: https://github.com/apache/pulsar/pull/17503#issuecomment-1239789994

   @massakam Please provide a correct documentation label for your PR.
   Instructions see [Pulsar Documentation Label Guide](https://docs.google.com/document/d/1Qw7LHQdXWBW9t2-r-A7QdFDBwmZh6ytB4guwMoXHqc0).


-- 
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