-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Avoid problem that topic becomes unavailable due to failure of cursor recovery #2673
Merged
Conversation
This file contains 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
rerun cpp tests |
sijie
changed the title
Avoid problem that topic becomes unavailable due to failure of cursor…
Avoid problem that topic becomes unavailable due to failure of cursor recovery
Sep 28, 2018
rerun cpp tests |
@massakam The change LGTM. It would be nice to have a test that reproduces this issue in the Mocked managed ledger tests, to ensure we won't have a regression in the future. |
rerun cpp tests |
rerun java8 tests |
@merlimat I have added the test. |
merlimat
approved these changes
Oct 2, 2018
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 was referenced Oct 2, 2018
sijie
pushed a commit
that referenced
this pull request
Oct 4, 2018
For a topic with metadata similar to #2673, IllegalArgumentException may occur in the following line: https://github.com/apache/pulsar/blob/b2484d92d5068d4f0699eb9c3d31640cb48f9dd0/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java#L655 This is the broker log when the exception has occurred: [invalid_range_error.txt](https://github.com/apache/pulsar/files/2442924/invalid_range_error.txt) It is because `readPosition` is ahead of `ledger.getLastPosition().getNext()`, so `ManagedCursorImpl#getNumberOfEntries()` should return 0 as the number of entries to read in that case. I think this issue and #2673 are the result of that `ledger.getLastPosition()` is no longer the real last of the managed ledger because of #1550.
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
This is a change to avoid #2666.
If a topic is under the following condition and the broker is restarted, that topic becomes unavailable and we can not send or receive messages.
cursorsLedgerId
included in the managed cursor info is -1markDeleteLedgerId
is between the two ledgers contained in the managed ledgerThis is because
position
gets ahead of the last position of the managed ledger, andIllegalArgumentException
occurs in the following line.pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Line 358 in d5e88c1
Modifications
If
position
gets ahead of the last position of the managed ledger when recovering the cursor,position
is adjusted to the last position.Result
Even a topic with metadata as described above, the cursor will be recovered successfully.