Skip to content
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

Merged
merged 2 commits into from
Mar 5, 2019

Conversation

ivankelly
Copy link
Contributor

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.

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.
@eolivelli
Copy link
Contributor

@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

@eolivelli
Copy link
Contributor

is it #1970 ?

@ivankelly
Copy link
Contributor Author

@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.

Copy link
Contributor

@eolivelli eolivelli left a 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private ?

Copy link
Contributor Author

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
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

@sijie
Copy link
Member

sijie commented Mar 4, 2019

please also cherry-pick the change to 4.9.1 and 4.8.3

@ivankelly
Copy link
Contributor Author

run bookkeeper-server bookie tests

@ivankelly ivankelly merged commit db5d7e7 into apache:master Mar 5, 2019
ivankelly added a commit that referenced this pull request Mar 5, 2019
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>
ivankelly added a commit that referenced this pull request Mar 5, 2019
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants