-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[improve][client] improve logic when ACK grouping tracker checks duplicated message id #15465
[improve][client] improve logic when ACK grouping tracker checks duplicated message id #15465
Conversation
…owledgmentsGroupingTracker`
@BewareMyPower |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorrry but I don't understanding the benefit of this patch.
We are not saving CPU cycles or fixing a bug.
Usually it is better to not change the code if there isn't a clear benefit.
'Don't fix things that are not broken'
+1 |
Hi, @eolivelli PR #10586 looks to change the original design logic when messageId is null. In the original logic, public boolean isDuplicate(MessageId messageId) {
if (messageId.compareTo(lastCumulativeAck) <= 0) {
// Already included in a cumulative ack
return true;
} else {
return pendingIndividualAcks.contains(messageId);
}
} But, in the current implementation, If public boolean isDuplicate(@NonNull MessageId messageId) {
final MessageId messageIdOfLastAck = lastCumulativeAck.messageId;
if (messageIdOfLastAck == null) {
return false;
}
if (messageId.compareTo(messageIdOfLastAck) <= 0) {
// Already included in a cumulative ack
return true;
} else {
return pendingIndividualAcks.contains(messageId);
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your clarification.
It would have been better do add a test case, but I understand it is something very hard to reproduce
…icated message id (apache#15465) (cherry picked from commit f6faeec) (cherry picked from commit d91c6d1)
…icated message id (apache#15465) (cherry picked from commit f6faeec) (cherry picked from commit 8b4d81e)
Motivation
#10586 introduces NPE check to avoid problems caused by recycling race conditions, but another conditional judgment in
isDuplicate
logic is not strongly dependent on themessageIdOfLastAck
, we can still usependingIndividualAcks.contains(messageId)
to judge again.Modifications
pendingIndividualAcks.contains(messageId)
to judgement whenmessageIdOfLastAck
is null.Verifying this change
Documentation
no-need-doc