[fix][client] In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal.#18154
Conversation
…when messageId is equal
| return; | ||
| } | ||
|
|
||
| if (messageId.compareTo(this.messageId) > 0) { |
There was a problem hiding this comment.
We already have the compare sult, I think we can improve it like
int compareResult = messageId.compareTo(this.messageId);
if (messageId.compareTo(this.messageId) > 0) {
/* ... */
} else if (compareResult == 0) {
/* compare bitSetRecyclable... */
}| return; | ||
| } | ||
|
|
||
| if (messageId.compareTo(this.messageId) > 0) { |
There was a problem hiding this comment.
seem compareTo has already compare the batchIndex.
so we don't need to do single check, right?There was a problem hiding this comment.
Yes, you are right
BewareMyPower
left a comment
There was a problem hiding this comment.
Actually I have another question. Could it happen in a real world case?
When the BitSetRecyclable object is not null, the messageId argument must be a BatchMessageIdImpl.
If messageId.equals(this.messageId), it must means this.messageId has the same batch index with messageId. In this case, could bitSetRecyclable be different with this.bitSetRecyclable?
Yes,you are right! Can the bitSetRecyclable variable be removed? Because we can know which sub-messages have been acknowledged just by the batch index:@BewareMyPower |

Motivation
In method LastCumulativeAck#update, bitSetRecyclable does not update when messageId is equal:
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java
Lines 660 to 669 in fa328a4
Modifications
When the messageId is equal, but the batch index is larger, the bitSetRecyclable should be updated:
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: lordcheng10#36