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 the topic in fenced state and can not recover. #11737
Merged
hangc0276
merged 3 commits into
apache:master
from
codelipenghui:penghui/fix-topic-fenced
Aug 25, 2021
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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.
I have one more question about this solution. Would it be necessary to call the callback for the OpAddEntry by using the "failed" method?
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.
+1. @codelipenghui, can you explain why we call
firstInQueue.failed
and then releasethis.data
and callthis.recycle()
without also callingthis.failed
? Note that thefailed
method has concurrency controls built in by using thecallbackUpdater
. Wouldn't we want to use those concurrency controls here as well?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.
@lhotari @michaeljmarshall As I mentioned in the PR description, there are 2 threads polling the add entry op from the queue, but here poll out the op from the queue but does not call the callback method of the op, this will lead to the
pendingWriteOps
of the topic can't change to 0 (before adding an entry, pendingWriteOps++. after entry add success for failed, pendingWriteOps--), so we should call the callback of the op here to make sure thependingWriteOps
can change to 0. The root cause of the issue is we missed some op callback calls here because the first op in the queue is not equaled to the current OpAddEntry(the previous behavior just throws an exception). So It's not about concurrency controls of thecallbackUpdater
.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.
Thank you for your clarification. I think I understand why we're calling
firstInQueue.failed
. I don't understand why we're callingthis.recycle
without also callingaddComplete
orfailed
. If I understand correctly, by callingthis.recycle
, we're going to setcallback = null;
without calling its callback. If my understanding is incorrect, can you explain why we're recyclingthis
without calling its callback? Thank you.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.
@codelipenghui The 2 threads polling seem to be part of the problem. Is that so?
One goal of the Managed Ledger design seems to be that there's a single thread per managed ledger executing operations. PR #11387 "Pin executor and scheduled executor threads for ManagedLedgerImpl" fixes some issues where this pinned executor solution wasn't used.
Just curious, would #11387 prevent the 2 threads polling the add entry op from the queue?
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.
Oh, I think I made a wrong change there, the
OpAddEntry.failed()
has released the data but looks like missed the object recycle, So we don't need to release it again.So a thread takes the op from the queue, it should call the callback and release the data.
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.
@lhotari Yes, I think run the
clearPendingAddEntries()
in the pinned executor can also fix the problemThere 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.
@codelipenghui Why isn't
this.failed(...)
called whenthis != firstInQueue
?I would be expecting something like this:
Is there a reason to not call
this.failed
?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.
@codelipenghui reading your previous answer, I would understand that clearPendingAddEntries is expected to call failed?
Since
failed
method has concurrency controls, I think it wouldn't cause any harm to callthis.failed
whenthis != firstInQueue
. No?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.
Yes, clearPendingAddEntries is expected to call failed.
And yes no harm to call
this.failed
, I think we only complete the op which comes from the queue is more clear here. All the add entry ops will add the queue, so someone poll the op from the queue, it should make sure theop.callback
has been called so that we don't need to care aboutthis.failed
, we just need to complete all the ops in the queue.