From cd577f605948894b51fbaab39d1df03a04dfd70f Mon Sep 17 00:00:00 2001 From: Akanksha Mahajan <43301668+akankshamahajan15@users.noreply.github.com> Date: Thu, 14 Dec 2023 13:45:06 -0800 Subject: [PATCH] Fix WRITE_STALL start_time (#12147) Summary: `Delayed` is set true in two cases. One is when `delay` is specified. Other one is in the `while` loop - https://github.com/facebook/rocksdb/blob/cd21e4e69d76ec4ec3b080c8cdae016ac2309cc5/db/db_impl/db_impl_write.cc#L1876 However start_time is not initialized in second case, resulting in time_delayed = immutable_db_options_.clock->NowMicros() - 0(start_time); Pull Request resolved: https://github.com/facebook/rocksdb/pull/12147 Test Plan: Existing CircleCI Reviewed By: cbi42 Differential Revision: D52173481 Pulled By: akankshamahajan15 fbshipit-source-id: fb9183b24c191d287a1d715346467bee66190f98 --- db/db_impl/db_impl_write.cc | 3 ++- unreleased_history/bug_fixes/fix_stall_counter.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 unreleased_history/bug_fixes/fix_stall_counter.md diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index 8add1e990b7..df67ba8c8f1 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1839,11 +1839,12 @@ Status DBImpl::DelayWrite(uint64_t num_bytes, WriteThread& write_thread, delay = 0; } TEST_SYNC_POINT("DBImpl::DelayWrite:Start"); + start_time = immutable_db_options_.clock->NowMicros(); + if (delay > 0) { if (write_options.no_slowdown) { return Status::Incomplete("Write stall"); } - start_time = immutable_db_options_.clock->NowMicros(); TEST_SYNC_POINT("DBImpl::DelayWrite:Sleep"); // Notify write_thread about the stall so it can setup a barrier and diff --git a/unreleased_history/bug_fixes/fix_stall_counter.md b/unreleased_history/bug_fixes/fix_stall_counter.md new file mode 100644 index 00000000000..be9e5122f8d --- /dev/null +++ b/unreleased_history/bug_fixes/fix_stall_counter.md @@ -0,0 +1 @@ +Fix a WRITE_STALL counter that was reporting wrong value in few cases.