-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] First entry will be skipped if opening NonDurableCursor while trimmed ledger is adding first entry. #24738
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
Conversation
…edger is adding first entry after trimmed.
|
@zhouyifan279 Please add the following content to your PR description and select a checkbox: |
lhotari
left a comment
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
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/NonDurableCursorTest.java
Outdated
Show resolved
Hide resolved
…l/NonDurableCursorTest.java Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24738 +/- ##
============================================
- Coverage 74.28% 74.18% -0.10%
- Complexity 33256 33605 +349
============================================
Files 1900 1901 +1
Lines 148398 148366 -32
Branches 17208 17200 -8
============================================
- Hits 110231 110072 -159
- Misses 29392 29522 +130
+ Partials 8775 8772 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com>
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 7a120f3) (cherry picked from commit 0e4e54b)
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 7a120f3) (cherry picked from commit 0e4e54b)
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 7a120f3) (cherry picked from commit f427b97)
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 7a120f3) (cherry picked from commit f427b97)
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com>
… while trimmed ledger is adding first entry. (apache#24738) Co-authored-by: Yunze Xu <xyzinfernity@163.com> Co-authored-by: Lari Hotari <lhotari@users.noreply.github.com> (cherry picked from commit 7a120f3)
Fixes #24737
Motivation
Pulsar ProtocolHandler, such as KoP, uses
ManagedLedgerImpl#asyncFindPositionto findstartCursorPositionand create a NonDurableCursor.When a topic's ledger is trimmed and is empty,
startCursorPositionwill be (currentLedgerId, -1).However, the created NonDurableCursor's readPosition is not stable if Topic ledger is adding a new entry simultaneously.
It may be (currentLedgerId, 0) or (currentLedgerId, 2).
We expect the created NonDurableCursor readPosition to always be (currentLedgerId, 0).
Modifications
In NonDurableCursorImpl constructor, we declare a reference to
ManagedLedgerImpl#lastConfirmedEntryand use it to compare withstartCursorPositionand toinitializeCursorPosition.Verifying this change
Run new test
NonDurableCursorTest#testOpenNonDurableCursorWhileLedgerIsAddingFirstEntryAfterTrimmedDoes this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: zhouyifan279#2