-
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] Compare batch index when accumulating acks and updating batchDeletedIndexes #18042
[fix][broker] Compare batch index when accumulating acks and updating batchDeletedIndexes #18042
Conversation
@eolivelli @codelipenghui @Technoboy- @Jason918 @AnonHxy PTAL,thanks! |
99e38d8
to
3567d01
Compare
@@ -105,6 +105,35 @@ private void recalculateWordsInUse() { | |||
wordsInUse = i+1; // The new logical size | |||
} | |||
|
|||
public int compareTo(BitSetRecyclable bitSetRecyclable) { | |||
long[] words1 = toLongArray(); |
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 suggest we avoid this memory copy in toLongArray
, just use words
and wordsInUse
instead.
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.
Fixed. @Jason918
PTAL,thanks!
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.
remove compareTo method,use nextSetBit instead of compareTo! @Jason918 PTAL,thanks!
batchDeletedIndexes.put(newPosition, BitSetRecyclable.create().resetWords(newPosition.ackSet)); | ||
lock.writeLock().lock(); | ||
try { | ||
setBatchDeletedIndexes(newPosition); |
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.
Looks like we just change to
BitSetRecyclable givenBitSet = BitSetRecyclable.create().resetWords(newPosition.ackSet);
batchDeletedIndexes.compute(newPosition,
(k, v) -> v == null || givenBitSet.nextClearBit(0) > v.nextClearBit(0) ?
givenBitSet : v);
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.
OK ,I will fix
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.
Fixed, PTAL,thanks! @codelipenghui
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.
nextClearBit is not suitable, because 0 means acked.
So use nextSetBit instead.
ff72a2c
to
6f89d69
Compare
@Jason918 @codelipenghui PTAL,thanks! |
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.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
227941e
to
7d6a3fd
Compare
Codecov Report
@@ Coverage Diff @@
## master #18042 +/- ##
=============================================
+ Coverage 34.91% 46.85% +11.94%
- Complexity 5707 17892 +12185
=============================================
Files 607 1574 +967
Lines 53396 128353 +74957
Branches 5712 14123 +8411
=============================================
+ Hits 18644 60144 +41500
- Misses 32119 62010 +29891
- Partials 2633 6199 +3566
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.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
/pulsarbot run-failure-checks |
@Technoboy- PTAL,thanks! |
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@AnonHxy @Technoboy- PTAL,thanks! |
… and check whether it is greater than the batch index of the previous ack
3393572
to
6ad5478
Compare
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
CI all passed: lordcheng10#28 |
@AnonHxy PTAL,thanks! |
/pulsarbot run-failure-checks |
7 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
… and check whether it is greater than the batch index of the previous ack (#18042) Co-authored-by: leolinchen <[email protected]>
Motivation
When accumulating acks, update the batch index in batchDeletedIndexes without checking whether it is greater than the batch index of the previous ack:
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Lines 1869 to 1872 in c732852
This may cause the index of ack in the batch to fall back.
Should be modified to:
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: lordcheng10#28