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 2023/01/11 13:39:02 UTC

[GitHub] [pulsar] AnonHxy opened a new pull request, #19191: [fix][client] Fix producer could send timeout when enable batching

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

   
   
   Fixes https://github.com/apache/pulsar/issues/19189
   
   ### Motivation
   
   Fixes https://github.com/apache/pulsar/issues/19189
   
   ### Modifications
   
   Trigger send if `batchMessageContainer` is full or schedule the batch flush task
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
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] codecov-commenter commented on pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#issuecomment-1379729771

   # [Codecov](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#19191](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e59871e) into [master](https://codecov.io/gh/apache/pulsar/commit/9ef54fd012e2f80f4499263f6ac4542b45c5bc15?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9ef54fd) will **decrease** coverage by `10.00%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/pulsar/pull/19191/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@              Coverage Diff              @@
   ##             master   #19191       +/-   ##
   =============================================
   - Coverage     47.22%   37.22%   -10.01%     
   + Complexity    10713     1989     -8724     
   =============================================
     Files           713      209      -504     
     Lines         69697    14453    -55244     
     Branches       7485     1576     -5909     
   =============================================
   - Hits          32914     5380    -27534     
   + Misses        33096     8490    -24606     
   + Partials       3687      583     -3104     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `37.22% <0.00%> (-10.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...va/org/apache/pulsar/client/impl/ProducerImpl.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1Byb2R1Y2VySW1wbC5qYXZh) | `15.62% <0.00%> (-0.04%)` | :arrow_down: |
   | [...r/service/schema/JsonSchemaCompatibilityCheck.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3NjaGVtYS9Kc29uU2NoZW1hQ29tcGF0aWJpbGl0eUNoZWNrLmphdmE=) | | |
   | [...ad/jcloud/provider/TieredStorageConfiguration.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGllcmVkLXN0b3JhZ2UvamNsb3VkL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ib29ra2VlcGVyL21sZWRnZXIvb2ZmbG9hZC9qY2xvdWQvcHJvdmlkZXIvVGllcmVkU3RvcmFnZUNvbmZpZ3VyYXRpb24uamF2YQ==) | | |
   | [...e/pulsar/proxy/server/ProxyReadTimeoutHandler.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLXByb3h5L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9wdWxzYXIvcHJveHkvc2VydmVyL1Byb3h5UmVhZFRpbWVvdXRIYW5kbGVyLmphdmE=) | | |
   | [...pache/pulsar/broker/stats/MBeanStatsGenerator.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zdGF0cy9NQmVhblN0YXRzR2VuZXJhdG9yLmphdmE=) | | |
   | [.../org/apache/pulsar/broker/admin/v1/Namespaces.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi92MS9OYW1lc3BhY2VzLmphdmE=) | | |
   | [...pache/pulsar/utils/auth/tokens/TokensCliUtils.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3V0aWxzL2F1dGgvdG9rZW5zL1Rva2Vuc0NsaVV0aWxzLmphdmE=) | | |
   | [...g/apache/bookkeeper/mledger/impl/PositionImpl.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9pbXBsL1Bvc2l0aW9uSW1wbC5qYXZh) | | |
   | [...oadbalance/extensions/data/TopBundlesLoadData.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb2FkYmFsYW5jZS9leHRlbnNpb25zL2RhdGEvVG9wQnVuZGxlc0xvYWREYXRhLmphdmE=) | | |
   | [.../jcloud/impl/BlockAwareSegmentInputStreamImpl.java](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGllcmVkLXN0b3JhZ2UvamNsb3VkL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ib29ra2VlcGVyL21sZWRnZXIvb2ZmbG9hZC9qY2xvdWQvaW1wbC9CbG9ja0F3YXJlU2VnbWVudElucHV0U3RyZWFtSW1wbC5qYXZh) | | |
   | ... and [496 more](https://codecov.io/gh/apache/pulsar/pull/19191?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   


-- 
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] HQebupt commented on pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
HQebupt commented on PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#issuecomment-1379739733

   Nice catch!


-- 
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] Technoboy- closed pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
Technoboy- closed pull request #19191: [fix][client] Fix producer could send timeout when enable batching
URL: https://github.com/apache/pulsar/pull/19191


-- 
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] Technoboy- merged pull request #19191: [fix][client] Fix producer could send timeout when enable batching

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


-- 
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] lhotari commented on pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
lhotari commented on PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#issuecomment-1380262893

   I don't fully agree on the fix. When looking at the logic, it feels that org.apache.pulsar.client.impl.AbstractBatchMessageContainer#haveEnoughSpace is wrong if a bug like this occurs. @codelipenghui @michaeljmarshall do you have a chance to check this PR although it has already been merged?


-- 
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] lhotari commented on pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
lhotari commented on PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#issuecomment-1380261367

   This is a good catch, but I didn't have a chance to review it before merging. 
   
   @Technoboy- Please wait for reviews from the people who have worked on the code when such issues are faced.
   


-- 
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] michaeljmarshall commented on a diff in pull request #19191: [fix][client] Fix producer could send timeout when enable batching

Posted by GitBox <gi...@apache.org>.
michaeljmarshall commented on code in PR #19191:
URL: https://github.com/apache/pulsar/pull/19191#discussion_r1068553187


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java:
##########
@@ -873,14 +869,23 @@ private boolean canAddToCurrentBatch(MessageImpl<?> msg) {
                 && batchMessageContainer.hasSameTxn(msg);
     }
 
+    private void triggerSendIfFullOrScheduleFlush(boolean isBatchFull) {
+        if (isBatchFull) {
+            batchMessageAndSend(false);
+        } else {
+            maybeScheduleBatchFlushTask();
+        }
+    }
+
     private void doBatchSendAndAdd(MessageImpl<?> msg, SendCallback callback, ByteBuf payload) {
         if (log.isDebugEnabled()) {
             log.debug("[{}] [{}] Closing out batch to accommodate large message with size {}", topic, producerName,
                     msg.getUncompressedSize());
         }
         try {
             batchMessageAndSend(false);
-            batchMessageContainer.add(msg, callback);
+            boolean isBatchFull = batchMessageContainer.add(msg, callback);
+            triggerSendIfFullOrScheduleFlush(isBatchFull);
             lastSendFuture = callback.getFuture();

Review Comment:
   Should this be before the call to `triggerSendIfFullOrScheduleFlush`? It is in the other usage of `triggerSendIfFullOrScheduleFlush`. However, we're in a `synchronized (this)` block, so it might be fine.



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