-
Notifications
You must be signed in to change notification settings - Fork 903
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
[DLOG] Avoid double read in readahead #1973
Conversation
There was a bug in the ReadAheadReader whereby, if it was in a paused state and the last segment it had read had been closed, then when a writer started writing new segments, the ReadAheadReader would issue a double read. This would end up triggering an error when it got to the end of the segment as the issued one of the issued reads would then be cancelled when the segment was closed. This fix adds an explicit state machine to the reader and moves all state transitions to run on the ordered executor, so only one read can ever be issued at a time.
@ivankelly did you see some error which is getting fixed by this patch ? I can't see any issue attached. Is this problem affecting production with 4.9 or is only a case that you found analysing the code ? cc @diegosalvi FYI |
is it #1970 ? |
@eolivelli the issue was observed by a customer running 4.7.3, but the code hasn't changed much since. The attached unit test will trigger it if you want to see the problem in action. |
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 left a minor comment.
I am not used to DL code so my review is not so "binding".
@@ -67,6 +67,15 @@ | |||
|
|||
private static final Logger logger = LoggerFactory.getLogger(ReadAheadEntryReader.class); | |||
|
|||
enum State { |
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.
private ?
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.
updated
case READING: | ||
case ERROR: | ||
case CLOSED: | ||
// do nothing |
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.
shall a log at trace level be useful ?
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.
nah, we already know if we're going to hit this branch from the debug log above.
please also cherry-pick the change to 4.9.1 and 4.8.3 |
run bookkeeper-server bookie tests |
There was a bug in the ReadAheadReader whereby, if it was in a paused state and the last segment it had read had been closed, then when a writer started writing new segments, the ReadAheadReader would issue a double read. This would end up triggering an error when it got to the end of the segment as the issued one of the issued reads would then be cancelled when the segment was closed. This fix adds an explicit state machine to the reader and moves all state transitions to run on the ordered executor, so only one read can ever be issued at a time. Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org> This closes #1973 from ivankelly/dlog-reader-crash-master (cherry picked from commit db5d7e7) Signed-off-by: Ivan Kelly <ivank@apache.org>
There was a bug in the ReadAheadReader whereby, if it was in a paused state and the last segment it had read had been closed, then when a writer started writing new segments, the ReadAheadReader would issue a double read. This would end up triggering an error when it got to the end of the segment as the issued one of the issued reads would then be cancelled when the segment was closed. This fix adds an explicit state machine to the reader and moves all state transitions to run on the ordered executor, so only one read can ever be issued at a time. Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org> This closes #1973 from ivankelly/dlog-reader-crash-master (cherry picked from commit db5d7e7) Signed-off-by: Ivan Kelly <ivank@apache.org>
There was a bug in the ReadAheadReader whereby, if it was in a paused
state and the last segment it had read had been closed, then when a
writer started writing new segments, the ReadAheadReader would issue a
double read. This would end up triggering an error when it got to the
end of the segment as the issued one of the issued reads would then be
cancelled when the segment was closed.
This fix adds an explicit state machine to the reader and moves all
state transitions to run on the ordered executor, so only one read can
ever be issued at a time.