From 3e02e66ca87e71d0a6e7907a7ca2071ef0167620 Mon Sep 17 00:00:00 2001 From: Dawid Medrek Date: Fri, 12 Jul 2024 12:55:24 +0200 Subject: [PATCH] db/hints: Move a constant value to the TU it's used in Until now, the constant `HINT_FILE_WRITE_TIMEOUT` was declared as a static member of `db::hints::manager`. However, the constant is only ever used in one translation unit, so it makes more sense to move it there and not include boilerplate in a header. --- db/hints/internal/hint_endpoint_manager.cc | 13 +++++++++++-- db/hints/manager.hh | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/db/hints/internal/hint_endpoint_manager.cc b/db/hints/internal/hint_endpoint_manager.cc index bab7a281ea..dfbac92b0f 100644 --- a/db/hints/internal/hint_endpoint_manager.cc +++ b/db/hints/internal/hint_endpoint_manager.cc @@ -11,6 +11,7 @@ // Seastar features. #include #include +#include #include #include #include @@ -20,18 +21,26 @@ #include "db/hints/internal/hint_logger.hh" #include "db/hints/internal/hint_storage.hh" #include "db/hints/manager.hh" +#include "db/timeout_clock.hh" #include "replica/database.hh" #include "utils/disk-error-handler.hh" #include "utils/runtime.hh" // STD. #include +#include #include #include namespace db::hints { namespace internal { +namespace { + +constexpr std::chrono::seconds HINT_FILE_WRITE_TIMEOUT = std::chrono::seconds(2); + +} // anonymous namespace + bool hint_endpoint_manager::store_hint(schema_ptr s, lw_shared_ptr fm, tracing::trace_state_ptr tr_state) noexcept { try { // Future is waited on indirectly in `stop()` (via `_store_gate`). @@ -41,9 +50,9 @@ bool hint_endpoint_manager::store_hint(schema_ptr s, lw_shared_ptr future<> { - return get_or_load().then([this, fm = std::move(fm), s = std::move(s), tr_state] (hints_store_ptr log_ptr) mutable { + return get_or_load().then([fm = std::move(fm), s = std::move(s), tr_state] (hints_store_ptr log_ptr) mutable { commitlog_entry_writer cew(s, *fm, db::commitlog::force_sync::no); - return log_ptr->add_entry(s->id(), cew, db::timeout_clock::now() + _shard_manager.HINT_FILE_WRITE_TIMEOUT); + return log_ptr->add_entry(s->id(), cew, db::timeout_clock::now() + HINT_FILE_WRITE_TIMEOUT); }).then([this, tr_state] (db::rp_handle rh) { auto rp = rh.release(); if (_last_written_rp < rp) { diff --git a/db/hints/manager.hh b/db/hints/manager.hh index 64041c2601..c0d80d94ca 100644 --- a/db/hints/manager.hh +++ b/db/hints/manager.hh @@ -104,7 +104,6 @@ public: static inline const std::string FILENAME_PREFIX{"HintsLog" + commitlog::descriptor::SEPARATOR}; // Non-const - can be modified with an error injection. static inline std::chrono::seconds hints_flush_period = std::chrono::seconds(10); - static constexpr std::chrono::seconds HINT_FILE_WRITE_TIMEOUT = std::chrono::seconds(2); private: static constexpr uint64_t MAX_SIZE_OF_HINTS_IN_PROGRESS = 10 * 1024 * 1024; // 10MB