diff --git a/file/writable_file_writer.cc b/file/writable_file_writer.cc index 6e3dd3b26..1ae66e21b 100644 --- a/file/writable_file_writer.cc +++ b/file/writable_file_writer.cc @@ -836,11 +836,13 @@ IOStatus WritableFileWriter::WriteDirectWithChecksum( // limiter size_t data_size = left; if (rate_limiter_ != nullptr && rate_limiter_priority_used != Env::IO_TOTAL) { - size_t size; - size = rate_limiter_->RequestToken(data_size, buf_.Alignment(), - writable_file_->GetIOPriority(), stats_, - RateLimiter::OpType::kWrite); - data_size -= size; + while (data_size > 0) { + size_t size; + size = rate_limiter_->RequestToken(data_size, buf_.Alignment(), + writable_file_->GetIOPriority(), + stats_, RateLimiter::OpType::kWrite); + data_size -= size; + } } { diff --git a/util/writable_file_io_priority_test.cc b/util/writable_file_io_priority_test.cc index 73ae1bcc1..22fdb9887 100644 --- a/util/writable_file_io_priority_test.cc +++ b/util/writable_file_io_priority_test.cc @@ -108,6 +108,8 @@ class WritableFileWriterIOPriorityTest : public testing::Test { IODebugContext* /*dbg*/) override { EXPECT_EQ(options.rate_limiter_priority, io_priority_); } + + bool IsSyncThreadSafe() const override { return true; } }; std::unique_ptr writer_; @@ -117,7 +119,7 @@ TEST_F(WritableFileWriterIOPriorityTest, Append) { writer_->Append(Slice("abc")); } -// TEST_F(WritableFileWriterIOPriorityTest, Pad) { writer_->Pad(10); } +TEST_F(WritableFileWriterIOPriorityTest, Pad) { writer_->Pad(500); } TEST_F(WritableFileWriterIOPriorityTest, Flush) { writer_->Flush(); }