mirror of https://github.com/facebook/rocksdb.git
Fix low priority write may cause crash when it is rate limited (#11932)
Summary: Fixed https://github.com/facebook/rocksdb/issues/11902 Pull Request resolved: https://github.com/facebook/rocksdb/pull/11932 Reviewed By: akankshamahajan15 Differential Revision: D50573356 Pulled By: hx235 fbshipit-source-id: adeb1abdc43b523b0357746055ce4a2eabde56a1
This commit is contained in:
parent
ab15d33566
commit
0ff7665c95
|
@ -1956,9 +1956,13 @@ Status DBImpl::ThrottleLowPriWritesIfNeeded(const WriteOptions& write_options,
|
|||
// a chance to run. Now we guarantee we are still slowly making
|
||||
// progress.
|
||||
PERF_TIMER_GUARD(write_delay_time);
|
||||
write_controller_.low_pri_rate_limiter()->Request(
|
||||
my_batch->GetDataSize(), Env::IO_HIGH, nullptr /* stats */,
|
||||
RateLimiter::OpType::kWrite);
|
||||
auto data_size = my_batch->GetDataSize();
|
||||
while (data_size > 0) {
|
||||
size_t allowed = write_controller_.low_pri_rate_limiter()->RequestToken(
|
||||
data_size, 0 /* alignment */, Env::IO_HIGH, nullptr /* stats */,
|
||||
RateLimiter::OpType::kWrite);
|
||||
data_size -= allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status::OK();
|
||||
|
|
|
@ -3882,16 +3882,26 @@ TEST_F(DBTest2, LowPriWrite) {
|
|||
ASSERT_OK(Put("", "", wo));
|
||||
ASSERT_EQ(1, rate_limit_count.load());
|
||||
|
||||
wo.low_pri = true;
|
||||
std::string big_value = std::string(1 * 1024 * 1024, 'x');
|
||||
ASSERT_OK(Put("", big_value, wo));
|
||||
ASSERT_LT(1, rate_limit_count.load());
|
||||
// Reset
|
||||
rate_limit_count = 0;
|
||||
wo.low_pri = false;
|
||||
ASSERT_OK(Put("", big_value, wo));
|
||||
ASSERT_EQ(0, rate_limit_count.load());
|
||||
|
||||
TEST_SYNC_POINT("DBTest.LowPriWrite:0");
|
||||
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
|
||||
|
||||
ASSERT_OK(dbfull()->TEST_WaitForCompact());
|
||||
wo.low_pri = true;
|
||||
ASSERT_OK(Put("", "", wo));
|
||||
ASSERT_EQ(1, rate_limit_count.load());
|
||||
ASSERT_EQ(0, rate_limit_count.load());
|
||||
wo.low_pri = false;
|
||||
ASSERT_OK(Put("", "", wo));
|
||||
ASSERT_EQ(1, rate_limit_count.load());
|
||||
ASSERT_EQ(0, rate_limit_count.load());
|
||||
}
|
||||
|
||||
TEST_F(DBTest2, RateLimitedCompactionReads) {
|
||||
|
|
Loading…
Reference in New Issue