-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] patch #5809: Fix the ledgerID not found cause NPE. #15098
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4956976
patch #5809: Fix the ledgerID not found cause NPE.
horizonzy f7c52fa
code style fix.
horizonzy f9f0667
error msg tweak.
horizonzy 8da51bb
for wait opReadEntry, the readPosition will recalculate, invalid shou…
horizonzy 23b3dd7
add test for wait OpReadEntry.
horizonzy 4ab367e
add unit for notify wait opReadEntry still invalid situation.
horizonzy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1750,6 +1750,12 @@ void asyncReadEntries(OpReadEntry opReadEntry) { | |
| opReadEntry.readEntriesFailed(new ManagedLedgerFencedException(), opReadEntry.ctx); | ||
| return; | ||
| } | ||
| if (opReadEntry.isInvalid()) { | ||
| opReadEntry.readEntriesFailed(new ManagedLedgerException.NoMoreEntriesToReadException("The ceilingKey(" | ||
| + "opReadEntry.readPosition) method is used to return the least key greater than or equal to the " | ||
| + "given key, or null if there is no such key"), opReadEntry.ctx); | ||
| return; | ||
| } | ||
|
|
||
| long ledgerId = opReadEntry.readPosition.getLedgerId(); | ||
|
|
||
|
|
@@ -2230,9 +2236,11 @@ void updateCursor(ManagedCursorImpl cursor, PositionImpl newPosition) { | |
| PositionImpl startReadOperationOnLedger(PositionImpl position, OpReadEntry opReadEntry) { | ||
| Long ledgerId = ledgers.ceilingKey(position.getLedgerId()); | ||
| if (null == ledgerId) { | ||
| opReadEntry.readEntriesFailed(new ManagedLedgerException.NoMoreEntriesToReadException("The ceilingKey(K key" | ||
| + ") method is used to return the least key greater than or equal to the given key, " | ||
| + "or null if there is no such key"), null); | ||
| opReadEntry.makeInvalid(); | ||
| return null; | ||
| } else { | ||
| // for wait opReadEntry, the readPosition will recalculate. | ||
| opReadEntry.makeValid(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here for wait opReadEntry, it maybe change from invalid to valid. So add this logicment. |
||
| } | ||
|
|
||
| if (ledgerId != position.getLedgerId()) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This changes the behavior of the method. So we need to go through all the usage of this method.
As far as I can see,
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpReadEntry.java
Line 142 in a242f03
OpReadEntry.createinpulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Line 765 in 5cf3fa0
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.
Thanks for your reminder. I have checked it, found another problem, I will fix it at another pr.
This one patch just for npe.
Uh oh!
There was an error while loading. Please reload this page.
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.
location 1:
It's useless code, I remove it at #15104. So needn't check it.
location 2:
It's a wait opReadEntry, when opAddEntry completed, it will nofity wait opReadEntry read again. The logicment is not conflict with this changes. And I fix the bad behavior when wait opReadEntry read at #15102
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.
Can you add a unit test to cover this path?
It seems
readPositionof this invalid OpReadEntry is used beforeasyncReadEntriesinhasMoreEntriesThere 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.
Maybe not, it will still be used in asyncReadEntries.
At line_768, the wait OpReadEntry set to property
WAITING_READ_OP_UPDATER.pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Line 768 in c163158
In notifyEntriesAvailable, get wait OpReadEntry from
WAITING_READ_OP_UPDATER, and handle it toasyncReadEntries.And in notifyEntriesAvailable, there be a bad behavior. fixes at #15102
pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Lines 2749 to 2772 in c163158
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.
Add unit to cover wait opReadEntry case. And close #15102, the handle push at this pr.
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.
all done, pls check it again when you convenient.