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

Fix possible race condition in checksum name generator #6662

Merged

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Jul 1, 2014

When three threads are trying to write checksums at the same time, it's possible for all three threads to obtain the same checksum file name A. Then the first thread enters the synchronized section, creates the file with name A and exits. The second thread enters the synchronized section, checks that A exists, creates file A+1 and exits the critical section. Then it proceeds to clean up and deletes all checksum files including A. If it happens before the third thread enters the synchronized section, it's possible for the third thread to check for A and since it no longer exists create the checksum file A the second time, which triggers "file _checksums-XXXXXXXXXXXXX was already written to" exception in MockDirectoryWrapper and fails recovery.

@imotov imotov added review and removed v2.0.0 labels Jul 1, 2014
@s1monw
Copy link
Contributor

s1monw commented Jul 1, 2014

LGTM

@s1monw s1monw removed the review label Jul 1, 2014
When three threads are trying to write checksums at the same time, it's possible for all three threads to obtain the same checksum file name A. Then the first thread enters the synchronized section, creates the file with name A and exits. The second thread enters the synchronized section, checks that A exists, creates file A+1 and exits the critical section. Then it proceeds to clean up  and deletes all checksum files including A. If it happens before the third thread enters the synchronized section, it's possible for the third thread to check for A and since it no longer exists create the checksum file A the second time, which triggers "file _checksums-XXXXXXXXXXXXX was already written to" exception in MockDirectoryWrapper and fails recovery.
@imotov imotov merged commit f14edef into elastic:master Jul 1, 2014
@clintongormley clintongormley changed the title [TEST] Fix possible race condition in checksum name generator Test: Fix possible race condition in checksum name generator Jul 9, 2014
@clintongormley clintongormley changed the title Test: Fix possible race condition in checksum name generator Internal: Fix possible race condition in checksum name generator Jul 16, 2014
@imotov imotov deleted the fix-race-condition-in-checksum-writer branch December 5, 2014 21:09
@clintongormley clintongormley changed the title Internal: Fix possible race condition in checksum name generator Fix possible race condition in checksum name generator Jun 7, 2015
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.

None yet

3 participants