Fix data race in accessing cached_range_tombstone_
#10680
Closed
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.
Summary: fix a data race introduced in #10547 (P5295241720), first reported by @pdillinger. The race is between the
std::atomic_load_explicit
in NewRangeTombstoneIteratorInternal and thestd::atomic_store_explicit
in MemTable::Add() that operate oncached_range_tombstone_
. P5295241720 shows thatatomic_store_explicit
initializes some mutex whichatomic_load_explicit
could be trying to calllock()
on at the same time. This fix moves the initialization to memtable constructor.Test plan:
USE_CLANG=1 COMPILE_WITH_TSAN=1 make -j24 whitebox_crash_test