Skip to content

Commit 2d57828

Browse files
committed
Check stop level trigger-0 before slowdown level-0 trigger
Summary: ... Test Plan: Can't repro the test failure, but let's see what jenkins says Reviewers: zagfox, sdong, ljin Reviewed By: sdong, ljin Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D23061
1 parent 659d2d5 commit 2d57828

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

db/column_family.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ void ColumnFamilyData::RecalculateWriteStallConditions() {
326326
"[%s] Stopping writes because we have %d immutable memtables "
327327
"(waiting for flush)",
328328
name_.c_str(), imm()->size());
329+
} else if (current_->NumLevelFiles(0) >=
330+
options_.level0_stop_writes_trigger) {
331+
write_controller_token_ = write_controller->GetStopToken();
332+
internal_stats_->AddCFStats(InternalStats::LEVEL0_NUM_FILES, 1);
333+
Log(options_.info_log,
334+
"[%s] Stopping writes because we have %d level-0 files",
335+
name_.c_str(), current_->NumLevelFiles(0));
329336
} else if (options_.level0_slowdown_writes_trigger >= 0 &&
330337
current_->NumLevelFiles(0) >=
331338
options_.level0_slowdown_writes_trigger) {
@@ -338,13 +345,6 @@ void ColumnFamilyData::RecalculateWriteStallConditions() {
338345
"[%s] Stalling writes because we have %d level-0 files (%" PRIu64
339346
"us)",
340347
name_.c_str(), current_->NumLevelFiles(0), slowdown);
341-
} else if (current_->NumLevelFiles(0) >=
342-
options_.level0_stop_writes_trigger) {
343-
write_controller_token_ = write_controller->GetStopToken();
344-
internal_stats_->AddCFStats(InternalStats::LEVEL0_NUM_FILES, 1);
345-
Log(options_.info_log,
346-
"[%s] Stopping writes because we have %d level-0 files",
347-
name_.c_str(), current_->NumLevelFiles(0));
348348
} else if (options_.hard_rate_limit > 1.0 &&
349349
score > options_.hard_rate_limit) {
350350
uint64_t kHardLimitSlowdown = 1000;

db/db_test.cc

+20
Original file line numberDiff line numberDiff line change
@@ -7827,6 +7827,26 @@ TEST(DBTest, MTRandomTimeoutTest) {
78277827
}
78287828
}
78297829

7830+
TEST(DBTest, Level0StopWritesTest) {
7831+
Options options = CurrentOptions();
7832+
options.level0_slowdown_writes_trigger = 2;
7833+
options.level0_stop_writes_trigger = 4;
7834+
options.disable_auto_compactions = 4;
7835+
options.max_mem_compaction_level = 0;
7836+
Reopen(&options);
7837+
7838+
// create 4 level0 tables
7839+
for (int i = 0; i < 4; ++i) {
7840+
Put("a", "b");
7841+
Flush();
7842+
}
7843+
7844+
WriteOptions woptions;
7845+
woptions.timeout_hint_us = 30 * 1000; // 30 ms
7846+
Status s = Put("a", "b", woptions);
7847+
ASSERT_TRUE(s.IsTimedOut());
7848+
}
7849+
78307850
} // anonymous namespace
78317851

78327852
/*

0 commit comments

Comments
 (0)