diff --git a/replica/database.hh b/replica/database.hh index 997c771416..381a2974d7 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -502,7 +502,7 @@ private: // This field cashes the last truncation time for the table. // The master resides in system.truncated table - db_clock::time_point _truncated_at = db_clock::time_point::min(); + std::optional _truncated_at; bool _is_bootstrap_or_replace = false; sstables::shared_sstable make_sstable(sstables::sstable_state state); @@ -520,9 +520,7 @@ public: void set_truncation_time(db_clock::time_point truncated_at) noexcept { _truncated_at = truncated_at; } - db_clock::time_point get_truncation_time() const noexcept { - return _truncated_at; - } + db_clock::time_point get_truncation_time() const; void notify_bootstrap_or_replace_start(); diff --git a/replica/table.cc b/replica/table.cc index d864734324..9b456e96ff 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -439,6 +439,14 @@ sstables::shared_sstable table::make_sstable() { return make_sstable(sstables::sstable_state::normal); } +db_clock::time_point table::get_truncation_time() const { + if (!_truncated_at) [[unlikely]] { + on_internal_error(dblog, ::format("truncation time is not set, table {}.{}", + _schema->ks_name(), _schema->cf_name())); + } + return *_truncated_at; +} + void table::notify_bootstrap_or_replace_start() { _is_bootstrap_or_replace = true; }