Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #9577.
This PR fixes a data race in the WAL, which can occur when writes and deletes are being executed concurrently. The WAL uses a buffer pool of
[]byte
when reading from the log. WAL entries are unmarshaled into these buffers and passed along to the relevant methods handling the differenttypes of entry (write, delete etc).
In the case of deletes, the keys that need to be deleted were being stored for later processing, however these keys were part of the backing array of initial buffer from the pool. As such, those keys could be written to at a future time when handling other parts of the WAL.
The original bug can be triggered as follows:
$ go test -c -race github.com/influxdata/influxdb/tsdb $ repeat 100 ./tsdb.test -test.run TestStore_Sketches
In
master
the race should appear after a few iterations. I've ran a few hundred iterations on this PR and it's 🍏 📗 💚