-
Notifications
You must be signed in to change notification settings - Fork 170
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 issue preventing reads after flush on a file handle #751
Conversation
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.
LGTM.
Acknowledging trade-off that we mitigate the regression preventing reads after flush but introducing a race condition into file overwrites (available since v1.4.0 released this month) which could prevent opening a file for writing immediately after closing a file. (@passaro should we add an ignored test for this? I can add one in a follow-up 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.
LGTM!
Signed-off-by: Daniel Carl Jones <djonesoa@amazon.com>
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.
LGTM:
- flush() is no-op for read;
- inode readers counter is decremented on
release
(accepted behaviour thatopen
for write following aclose
may fail for short period of time); - eager initialisation of file handles to avoid FH being readable when we already have a scheduled work to write to it
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.
LGTM
Description of change
Fix a regression introduced in 0030b0a where closing (
flush
) a file descriptor would prevent subsequent reads on the corresponding file handle. The issue was caused byflush
setting the internal state of the file handle toClosed
and decrementing the number of readers for the inode, which is used to disallow overwrites when there are open read file handles.This PR includes 2 main changes:
Closed
state and revertsflush
to a no op for read file handles. The number of readers for an inode is decremented only onrelease
.open
eagerly discriminate between READ and WRITE, rather than on first read or write (or flush or release). This reverts the opposite change in Allow file overwrites #487 and allows to report error conditions onopen
when appropriate rather than on subsequent operations.Relevant issues: #749
Does this change impact existing behavior?
Because
release
is async, there is a race condition when trying to overwrite a file immediately after closing a read file handle on it, which results in the overwrite to occasionally fail on open.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).