-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Fix duplicate increment of ADD_OP_COUNT_UPDATER in OpAddEntry #24502
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
Conversation
|
@3pacccccc Please add the following content to your PR description and select a checkbox: |
…micConfigurationTopicAutoCreationPartitioned (apache#24505)
|
|
||
| // internally asyncAddEntry() will take the ownership of the buffer and release it at the end | ||
| addOpCount = ManagedLedgerImpl.ADD_OP_COUNT_UPDATER.incrementAndGet(ml); | ||
| addOpCount = ManagedLedgerImpl.ADD_OP_COUNT_UPDATER.get(ml); |
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.
How about remove this line instead of ManagedLedgerImpl.ADD_OP_COUNT_UPDATER.get(ml) ?
OpAddEntry.addOpCount was already set in OpAddEntry.createOpAddEntryNoRetainBuffer
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.
Yes, this makes more sense. Thanks for pointing it out. I've already removed it,please take a look again
…testDynamicConfigurationTopicAutoCreationPartitioned (apache#24505)" This reverts commit e4de9c0.
…ache#24501)" This reverts commit 0bdce23.
…o all test (apache#24492)" This reverts commit 13e0a7b.
Motivation
Currently, when adding a message to a ledger,
ManagedLedgerImpl.ADD_OP_COUNT_UPDATERis incremented twice:createOpAddEntryNoRetainBuffer()when creating theOpAddEntryOpAddEntry.initiate()This double increment leads to incorrect operation counting and potential metric inaccuracies.

here's the example I've tested on my local.
Modifications
OpAddEntry.initiate()fromincrementAndGet()toget()to prevent duplicate countingtestAddOpCountWithMessageAdd()to verify the correct increment behaviorVerifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
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#11