Skip to content

Fix race listing readable files #198

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

Merged
merged 2 commits into from
Sep 17, 2014
Merged

Fix race listing readable files #198

merged 2 commits into from
Sep 17, 2014

Conversation

engelsanchez
Copy link
Contributor

A race existed as demonstrated by the newly added
list_data_files_race_test test. When listing readable files from a
Bitcask directory for merging and such, the current write or merge
output files should never be listed along with the other files. This
could lead to merges trying to read active files while they are being
written.

Now, the code fetches the current merge and write files, lists the
directory contents, filtering those out, and checks again if the merge
and write file have changed. If they have, we try again, only succeeding
if no changes have happened in between.

This PR also removes some code that seems to indicate somebody saw
the race at some point. Alas, it was fixed in a crazy, crazy way.

This addresses issue #194

This test shows what happens when listing the readable files from a
Bitcask directory. The list should not include the active write or merge
files. But if those change after the code fetches the name of the
current one, the listing will contain the new active write and/or merge
files, skipping the *previous* write or merge file. That would be bad.

The test uses meck to return the filename, then in one go write a new
one to simulate the race.
A race existed as demonstrated by the newly added
list_data_files_race_test test. When listing readable files from a
Bitcask directory for merging and such, the current write or merge
output files should never be listed along with the other files. This
could lead to merges trying to read active files while they are being
written.

Now, the code fetches the current merge and write files, lists the
directory contents, filtering those out, and checks again if the merge
and write file have changed. If they have, we try again, only succeeding
if no changes have happened in between.
@slfritchie
Copy link
Contributor

+1 694480f

I disagree that the old code was crazy: it was detecting if a race happened in a different way. As you found, it wasn't used consistently, which was bad.

Review + 10 hours QuickCheck+PULSE look fine.

borshop added a commit that referenced this pull request Sep 17, 2014
Fix race listing readable files

Reviewed-by: slfritchie
@slfritchie
Copy link
Contributor

@borshop merge

@borshop borshop merged commit 694480f into 1.7 Sep 17, 2014
@engelsanchez
Copy link
Contributor Author

Let's discuss the insanity of that code after a few beers one of these days. Thanks!

@seancribbs seancribbs deleted the bugfix/list-files-race branch April 1, 2015 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants