Skip to content
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

Conversation

BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Jan 9, 2025

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-null ackSet.

Modifications

  • Add an ackBatchPosition method to handle Optional objects correctly with elegant and clear code.
  • Replace BitSetRecyclable with BitSet as the value type of batchDeletedIndexes to simplify the unnecessarily complicated code of calling recycle(). For example, if recycle() is called in a callback of ConcurrentSkipListMap#compute, it could be called multiple times. Additionally, the optimization for GC is not provided because BitSetRecyclable cannot avoid the memory allocation of its underlying long arrays.
  • Mark batchDeletedIndexes as @Nullable and check if it's not null instead of getConfig().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:

@BewareMyPower BewareMyPower self-assigned this Jan 9, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 9, 2025
@BewareMyPower BewareMyPower added type/bug The PR fixed a bug or issue reported a bug area/broker labels Jan 9, 2025
@lhotari lhotari added this to the 4.1.0 milestone Jan 9, 2025
@BewareMyPower BewareMyPower marked this pull request as draft January 10, 2025 11:40
@BewareMyPower BewareMyPower marked this pull request as ready for review January 14, 2025 05:45
Copy link
Member

@dao-jun dao-jun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 74.14%. Comparing base (bbc6224) to head (664fe46).
Report is 846 commits behind head on master.

Files with missing lines Patch % Lines
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 75.00% 5 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
inttests 26.67% <35.71%> (+2.09%) ⬆️
systests 23.15% <35.71%> (-1.18%) ⬇️
unittests 73.67% <75.00%> (+0.82%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...rg/apache/bookkeeper/mledger/impl/AckSetState.java 100.00% <ø> (ø)
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 79.20% <75.00%> (-0.10%) ⬇️

... and 1031 files with indirect coverage changes

@BewareMyPower BewareMyPower merged commit c92930f into apache:master Jan 14, 2025
59 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-async-mark-delete-npe branch January 14, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-not-needed Your PR changes do not impact docs ready-to-test release/3.0.9 release/3.3.4 release/4.0.2 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants