[fix][broker] Fix acked count calculation when acknowledging with transaction #25049
+187
−17
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
This PR fixes an issue with the acked count calculation during individual message acknowledgment with transaction when dealing with messages that no longer exist in the pending acknowledgment list. The problem occurs specifically when acknowledging messages that not exist, which leads to incorrect acked count calculations and potential negative unacked message counts.
you can reproduce in
TransactionEndToEndTestlike below:and you can see console output like:
Modifications
Consumer.java:
Modified
getAckOwnerConsumerAndBatchSizeto return batch size 0 for non-existent messagesAdded check in individualAckWithTransaction to set ackedCount = 0 when batchSize <= 0
Improved logging for better debugging of invalid acknowledgment attempts
MessageIndividualAckTest.java:
Added tests for normal and transactional individual acknowledgments
Tests verify correct behavior with non-existent messages for both
SharedandKey_Sharedsubscription typesConfirms that acked counts are properly calculated (0 for non-existent messages, correct counts for valid messages)
TransactionEndToEndTest.java:
Verifying this change
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: 3pacccccc#33