Skip to content

Commit c6bc3ea

Browse files
authored
fix(tiering): Cooldown for DiskStorage::Grow() retries (#5803)
Cooldown for DiskStorage::Grow() retries
1 parent 6221169 commit c6bc3ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/server/tiering/disk_storage.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ error_code DiskStorage::TryGrow(off_t grow_size) {
204204
if (alloc_.capacity() + ExternalAllocator::kExtAlignment >= static_cast<size_t>(max_size_))
205205
return make_error_code(errc::file_too_large);
206206

207+
// Don't try again immediately, most likely it won't succeed ever.
208+
const uint64_t kCooldownTime = 100'000'000; // 100ms
209+
if (grow_.last_err && (ProactorBase::GetMonotonicTimeNs() - grow_.timestamp_ns) < kCooldownTime)
210+
return make_error_code(errc::operation_canceled);
211+
207212
if (std::exchange(grow_.pending, true)) {
208213
LOG_EVERY_T(WARNING, 1) << "Blocked on concurrent grow";
209214
return make_error_code(errc::operation_in_progress);
@@ -212,6 +217,7 @@ error_code DiskStorage::TryGrow(off_t grow_size) {
212217
off_t end = alloc_.capacity();
213218
grow_.last_err = DoFiberCall(&SubmitEntry::PrepFallocate, backing_file_->fd(), 0, end, grow_size);
214219
grow_.pending = false;
220+
grow_.timestamp_ns = ProactorBase::GetMonotonicTimeNs();
215221
grow_.ev.notifyAll();
216222

217223
if (!grow_.last_err)

src/server/tiering/disk_storage.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ class DiskStorage {
6464
uint64_t heap_buf_alloc_cnt_ = 0, reg_buf_alloc_cnt_ = 0;
6565

6666
struct {
67-
bool pending = false;
67+
bool pending = false; // whether currently in progress
6868
std::error_code last_err;
69-
util::fb2::EventCount ev;
70-
} grow_;
69+
uint64_t timestamp_ns; // when last os finished (with any status)
70+
util::fb2::EventCount ev; // woken up when in-progress op finishes
71+
} grow_; // status of latest blocking Grow() operation
7172

7273
std::unique_ptr<util::fb2::LinuxFile> backing_file_;
7374
ExternalAllocator alloc_;

0 commit comments

Comments
 (0)