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.
This commit is contained in:
Dawid Medrek
2024-07-12 12:55:24 +02:00
parent b9abad0515
commit 3e02e66ca8
2 changed files with 11 additions and 3 deletions

View File

@@ -11,6 +11,7 @@
// Seastar features.
#include <seastar/core/do_with.hh>
#include <seastar/core/seastar.hh>
#include <seastar/core/shared_mutex.hh>
#include <seastar/core/sleep.hh>
#include <seastar/core/smp.hh>
#include <seastar/core/sstring.hh>
@@ -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 <algorithm>
#include <chrono>
#include <utility>
#include <vector>
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<const frozen_mutation> 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<const frozen_
shard_stats().size_of_hints_in_progress += mut_size;
return with_shared(file_update_mutex(), [this, fm, s, tr_state] () mutable -> 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) {

View File

@@ -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