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/08/09 10:06:47 UTC

[GitHub] [pulsar] congbobo184 opened a new pull request, #17016: [fix][broker] fix ack with txn compute ackedCount error

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

   issue: 
   reproduce:
   1. redeliver one consumer received message of a batch message, will remove this message from this consumer pending acks
   2. if this message is removed and doesn't redeliver to another consumer or this consumer, we ack another message in the same batch
   3. to compute the consumer unackedCount will get an incorrect batch size, because the message don't in any consumer pending acks
   ### Motivation
   get correct batch size to compute the consumer unackedCount
   ### Modification
   use the correct batch size from the `messageIdDate`
   ### Verifying this change
   add the test
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
     - The rest endpoints: (no)
     - The admin cli options: (no)
     - Anything that affects deployment: (no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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] Jason918 commented on pull request #17016: [fix][txn] fix ack with txn compute ackedCount error

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

   @Technoboy- Ping
   @congbobo184 Please resolve the conflicts.


-- 
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] Jason918 commented on pull request #17016: [fix][txn] fix ack with txn compute ackedCount error

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

   @Technoboy- Ping
   @congbobo184 Please resolve the conflicts.


-- 
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] Jason918 merged pull request #17016: [fix][txn] fix ack with txn compute ackedCount error

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


-- 
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] gaoran10 commented on a diff in pull request #17016: [fix][txn] fix ack with txn compute ackedCount error

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -523,25 +523,31 @@ private CompletableFuture<Long> individualAckWithTransaction(CommandAck ack) {
         LongAdder totalAckCount = new LongAdder();
         for (int i = 0; i < ack.getMessageIdsCount(); i++) {
             MessageIdData msgId = ack.getMessageIdAt(i);
-            PositionImpl position;
+            PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
+            // acked count at least one
             long ackedCount = 0;
-            long batchSize = getBatchSize(msgId);
+            long batchSize = 0;

Review Comment:
   Ok, If not batch message, the batch size should be 0, right?



-- 
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] congbobo184 commented on a diff in pull request #17016: [fix][broker] fix ack with txn compute ackedCount error

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -523,25 +523,31 @@ private CompletableFuture<Long> individualAckWithTransaction(CommandAck ack) {
         LongAdder totalAckCount = new LongAdder();
         for (int i = 0; i < ack.getMessageIdsCount(); i++) {
             MessageIdData msgId = ack.getMessageIdAt(i);
-            PositionImpl position;
+            PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
+            // acked count at least one
             long ackedCount = 0;
-            long batchSize = getBatchSize(msgId);
+            long batchSize = 0;

Review Comment:
   if not batch message, the batchSize can not be able to 1



-- 
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 #17016: [fix][txn] fix ack with txn compute ackedCount error

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

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


[GitHub] [pulsar] gaoran10 commented on a diff in pull request #17016: [fix][broker] fix ack with txn compute ackedCount error

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -523,25 +523,31 @@ private CompletableFuture<Long> individualAckWithTransaction(CommandAck ack) {
         LongAdder totalAckCount = new LongAdder();
         for (int i = 0; i < ack.getMessageIdsCount(); i++) {
             MessageIdData msgId = ack.getMessageIdAt(i);
-            PositionImpl position;
+            PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
+            // acked count at least one
             long ackedCount = 0;
-            long batchSize = getBatchSize(msgId);
+            long batchSize = 0;

Review Comment:
   The default value may be 1.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -523,25 +523,31 @@ private CompletableFuture<Long> individualAckWithTransaction(CommandAck ack) {
         LongAdder totalAckCount = new LongAdder();
         for (int i = 0; i < ack.getMessageIdsCount(); i++) {
             MessageIdData msgId = ack.getMessageIdAt(i);
-            PositionImpl position;
+            PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
+            // acked count at least one
             long ackedCount = 0;
-            long batchSize = getBatchSize(msgId);
+            long batchSize = 0;
+            if (msgId.hasBatchSize()) {
+                batchSize = msgId.getBatchSize();
+                // ack batch messages set ackeCount = 1, if has ackSets will recompute

Review Comment:
   ```suggestion
                   // ack batch messages set ackeCount = batchSize, if has ackSets will recompute
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -523,25 +523,31 @@ private CompletableFuture<Long> individualAckWithTransaction(CommandAck ack) {
         LongAdder totalAckCount = new LongAdder();
         for (int i = 0; i < ack.getMessageIdsCount(); i++) {
             MessageIdData msgId = ack.getMessageIdAt(i);
-            PositionImpl position;
+            PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
+            // acked count at least one
             long ackedCount = 0;
-            long batchSize = getBatchSize(msgId);
+            long batchSize = 0;
+            if (msgId.hasBatchSize()) {
+                batchSize = msgId.getBatchSize();
+                // ack batch messages set ackeCount = 1, if has ackSets will recompute
+                ackedCount = msgId.getBatchSize();
+                positionsAcked.add(new MutablePair<>(position, msgId.getBatchSize()));
+            } else {
+                // ack no batch message set ackedCount = 1
+                ackedCount = 1;
+                positionsAcked.add(new MutablePair<>(position, (int) batchSize));
+            }
             Consumer ackOwnerConsumer = getAckOwnerConsumer(msgId.getLedgerId(), msgId.getEntryId());
             if (msgId.getAckSetsCount() > 0) {
                 long[] ackSets = new long[msgId.getAckSetsCount()];
                 for (int j = 0; j < msgId.getAckSetsCount(); j++) {
                     ackSets[j] = msgId.getAckSetAt(j);
                 }
                 position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId(), ackSets);
+                // recompute ackedCount
                 ackedCount = getAckedCountForTransactionAck(batchSize, ackSets);
             } else {
                 position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());

Review Comment:
   Maybe we can remove this line.



-- 
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] congbobo184 commented on pull request #17016: [fix][txn] fix ack with txn compute ackedCount error

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

   @Technoboy- transaction ack command will carry the batchSize, if the batchSize is not in pendingAcks(the message redeliver hasn't been sent to any consumer), we will not get the correct batch size. So I think in Transaction ack, we uniformly use command carried batch size is ok


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