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

   ### Motivation
   
   https://github.com/apache/pulsar/pull/14185 had a minor bug in that the 
first message sent to the producer would always deliver because 
`lastBatchSendNanoTime` was not initialized correctly. In 
https://github.com/apache/pulsar/pull/15406, we improved the initialization, 
but I am concerned that it didn't completely solve the problem because the 
counter is initialized before grabbing the connection, which will often take 
longer than the `batchingMaxPublishDelayMicros`, which defaults to 1 
millisecond. This PR aims to solve the underlying problem by only initializing 
the timer once the producer is connected to the topic. Note that this change 
aligns with the original behavior, which started the scheduled task once the 
producer connected to the topic.
   
   If possible, I hope to get this merged and cherry-picked to branch-2.11 as 
soon as possible.
   
   ### Modifications
   
   * Update the `batchFlushTask()` method to handle the initialization case for 
`lastBatchSendNanoTime`.
   * Remove the initialization for `lastBatchSendNanoTime` in the constructor.
   
   ### Verifying this change
   
   This test is fairly trivial to verify, but is hard to test for. I manually 
verified using debug logs to see that the time is correctly initialized on the 
first run and not afterwards.
   
   ### Documentation
   
   - [x] `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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to