Skip to content

Commit 4e8321b

Browse files
committed
Boost access before mutex is unlocked
Summary: This moves the use of versions_ to before the mutex is unlocked to avoid a possible race. Task ID: # Blame Rev: Test Plan: make check Revert Plan: Database Impact: Memcache Impact: Other Notes: EImportant: - begin *PUBLIC* platform impact section - Bugzilla: # - end platform impact - Reviewers: haobo, dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D15279
1 parent 83681bf commit 4e8321b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

db/db_impl.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -3200,15 +3200,15 @@ Status DBImpl::MakeRoomForWrite(bool force,
32003200
// individual write by 0-1ms to reduce latency variance. Also,
32013201
// this delay hands over some CPU to the compaction thread in
32023202
// case it is sharing the same core as the writer.
3203+
uint64_t slowdown =
3204+
SlowdownAmount(versions_->current()->NumLevelFiles(0),
3205+
options_.level0_slowdown_writes_trigger,
3206+
options_.level0_stop_writes_trigger);
32033207
mutex_.Unlock();
32043208
uint64_t delayed;
32053209
{
32063210
StopWatch sw(env_, options_.statistics.get(), STALL_L0_SLOWDOWN_COUNT);
3207-
env_->SleepForMicroseconds(
3208-
SlowdownAmount(versions_->current()->NumLevelFiles(0),
3209-
options_.level0_slowdown_writes_trigger,
3210-
options_.level0_stop_writes_trigger)
3211-
);
3211+
env_->SleepForMicroseconds(slowdown);
32123212
delayed = sw.ElapsedMicros();
32133213
}
32143214
RecordTick(options_.statistics.get(), STALL_L0_SLOWDOWN_MICROS, delayed);

0 commit comments

Comments
 (0)