-
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
[fix][broker] Fix possible mark delete NPE when batch index ack is enabled #23833
Conversation
pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/BitSetRecyclable.java
Outdated
Show resolved
Hide resolved
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.
lgtm
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23833 +/- ##
============================================
+ Coverage 73.57% 74.14% +0.57%
+ Complexity 32624 32187 -437
============================================
Files 1877 1853 -24
Lines 139502 143562 +4060
Branches 15299 16302 +1003
============================================
+ Hits 102638 106444 +3806
+ Misses 28908 28727 -181
- Partials 7956 8391 +435
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.BitSetRecyclable
withBitSet
as the value type ofbatchDeletedIndexes
to simplify the unnecessarily complicated code of callingrecycle()
. For example, ifrecycle()
is called in a callback ofConcurrentSkipListMap#compute
, it could be called multiple times. Additionally, the optimization for GC is not provided becauseBitSetRecyclable
cannot avoid the memory allocation of its underlying long arrays.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: