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

tsm: cache: race condition exists between compactor and backup #5802

Closed
jonseymour opened this issue Feb 23, 2016 · 1 comment
Closed

tsm: cache: race condition exists between compactor and backup #5802

jonseymour opened this issue Feb 23, 2016 · 1 comment

Comments

@jonseymour
Copy link
Contributor

A second race condition exists in the implementation of the TSM cache system.

The issue exists because no lock exists that prevents two goroutines attempting to execute Engine.WriteSnapshots() at the same time. When this happens, the second thread to start executing Cache.Snapshots() can interfere with the first thread which is executing Cache.Deduplicate().

An example of how this could occur in real life is that the period compaction happens at the same time that a BACKUP is issued.

This race condition is implied by the lack of synchronization between two invocations of WriteSnapshot executing on different threads; it is demonstrated by a test case that will be submitted along with a proposed fix.

(A proposed fix for this was rolled up into #5689 but since that PR has been discard in favour of #5789, this issue has been opened to separately document, explain, demonstrate and fix this issue.)

The issue is easily fixed by introducing a mutex that guards the execution that occurs between Snapshot() and ClearSnapshot(),

@jonseymour
Copy link
Contributor Author

Closed via #5807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant