Skip to content

Commit

Permalink
fix data race
Browse files Browse the repository at this point in the history
Summary:
Fix a TSAN failure in `DBRangeDelTest.ValidLevelSubcompactionBoundaries`:
https://gist.github.com/miasantreble/712e04b4de2ff7f193c98b1acf07e899
Closes facebook#3691

Differential Revision: D7541400

Pulled By: miasantreble

fbshipit-source-id: b0b4538980bce7febd0385e61d6e046580bcaefb
  • Loading branch information
miasantreble authored and facebook-github-bot committed Apr 9, 2018
1 parent bde1c1a commit f3a1d9e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,9 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
// because &w is ensuring that all new writes get queued.
{
EnvOptions opt_env_opts = env_->OptimizeForManifestWrite(env_options_);
// Before releasing mutex, make a copy of mutable_cf_options and pass to
// `PrepareApply` to avoided a potential data race with backgroundflush
MutableCFOptions mutable_cf_options_copy(mutable_cf_options);
mu->Unlock();

TEST_SYNC_POINT("VersionSet::LogAndApply:WriteManifest");
Expand Down Expand Up @@ -2876,7 +2879,7 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,

if (!w.edit_list.front()->IsColumnFamilyManipulation()) {
// This is cpu-heavy operations, which should be called outside mutex.
v->PrepareApply(mutable_cf_options, true);
v->PrepareApply(mutable_cf_options_copy, true);
}

// Write new record to MANIFEST log
Expand Down

0 comments on commit f3a1d9e

Please sign in to comment.