-
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
[fix][broker] Fix possible mark delete NPE when batch index ack is enabled #23833
base: master
Are you sure you want to change the base?
[fix][broker] Fix possible mark delete NPE when batch index ack is enabled #23833
Conversation
@@ -1211,6 +1211,9 @@ public void recycle() { | |||
if (recyclerHandle != null) { | |||
this.clear(); | |||
recyclerHandle.recycle(this); | |||
// Reset with null so that recycle() can be called many times but only the 1st time takes effect. |
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.
If we set the recycleHandler = null
here, looks like it will downgrade to shortlive objects
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. What's the issue here?
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 just wandering that since it can be downgrade to shortlive objects, why not just new BitSetRecyclable()
here directly, so we don't need to call recycle
and don't need to set recycleHandle=null
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.
By this way, we can keep the semantic align, WDYT?
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 agree. I will use BitSet
instead. Using a recyclable object is very error-prone in non-trivial cases. In this specific case, it's used as the value of a map and we must guarantee recycle()
is called when the value is removed.
The benefit of recycler is a pre-mature optimization IMO.
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.
+1, use bitset here directly will not lead to performance regression, and makes it more clearly. The key point is BitSet#words
field, since we just wrap the given ackSet
by BitSet, it is OK to use BitSet
instead.
Motivation
MLPendingAckStoreTest#testMainProcess
will fail by NPE if batch index ACK is enabled. The NPE happens when the position argument does not has a non-nullackSet
.Modifications
ackBatchPosition
method to handleOptional
objects correctly with elegant and clear code.BitSetRecycable#recycle()
call safe to be called multiple times so that it can be called inConcurrentSkipListMap
's callback, which is not guaranteed to be called only once.batchDeletedIndexes
as@Nullable
and check if it's not null instead ofgetConfig().isDeletionAtBatchIndexLevelEnabled()
to eliminate all NPE warnings.Verifying this change
Enable batch index ACK in
MLPendingAckStoreTest
and guarantee this test passes.Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: