[Bug] When using the admin.topics().skipMessages API, the actual number of skipped messages may be less than the expected number when the value of skipNumber is greater than 8. #20262
Labels
type/bug
The PR fixed a bug or issue reported a bug
Search before asking
Version
latest version
Minimal reproduce step
When I artificially created 50 hollow messages and skipped 20 messages, only 14 messages were actually skipped.
What did you expect to see?
The expected number of skipped messages is equal to the actual number of skipped messages.
What did you see instead?
The actual number of skips is less than the expected number of skips.
Anything else?
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Lines 1772 to 1785 in e956db7
The reason for this issue is that the
recycle()
function reuses objects, causing the object referenced byr
to change during runtime. When the loop count is greater than 8, the else block is entered, leading to an incorrect calculation of the message count.I think there are two methods to fix this issue.
The first method is to perform a copy before assignment, similar to the following:
The second method is to remove
recyclePositionRangeConverter
.any other suggestions for a better solution?
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: