[fix][client] Fix unable to send cumulative acknowledgment for last messageId of a batch when enable batch index acknowledgment - #18531
Closed
coderzc wants to merge 1 commit into
Closed
Conversation
…ch when enable batch index acknowledgment
congbobo184
reviewed
Nov 18, 2022
| new BatchMessageIdImpl(newMessageId.ledgerId, newMessageId.entryId, newMessageId.partitionIndex, | ||
| Integer.MAX_VALUE); | ||
| } | ||
| if (newMessageId.compareTo(lastMessageId) > 0) { |
Contributor
There was a problem hiding this comment.
LGTM! one question : why not modify the compareTo method directly?
Member
Author
There was a problem hiding this comment.
I'm not sure whether modifying MessageImpl.compareTo and BatchMessageIdImpl.compareTo can lead to other problems, I don't know why the previous logic of compareTo was like that.
| if (newMessageId instanceof BatchMessageIdImpl && !(lastMessageId instanceof BatchMessageIdImpl)) { | ||
| lastMessageId = | ||
| new BatchMessageIdImpl(lastMessageId.ledgerId, lastMessageId.entryId, lastMessageId.partitionIndex, | ||
| Integer.MAX_VALUE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When enable batch index acknowledgment, we are unable to send a cumulative acknowledgment for the last messageId of a batch, the root cause is the last messageId of a batch doesn't carry with batch index but due to the wrong comparison in
org.apache.pulsar.client.impl.LastCumulativeAck#updatemake the last messageId can't be sent.pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java
Lines 228 to 229 in 545f33f
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java
Lines 624 to 632 in 545f33f
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageIdImpl.java
Lines 71 to 84 in 82237d3
Modifications
Fix the wrong comparison in
org.apache.pulsar.client.impl.LastCumulativeAck#update, change it to(x,y,z) >= (x,y,z,w).I'm not sure whether modifying
MessageImpl.compareToandBatchMessageIdImpl.compareTocan lead to other problems, so just modifyorg.apache.pulsar.client.impl.LastCumulativeAck#updateVerifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
testAcknowledgeCumulative
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: coderzc#32