table: get_truncation_time: check _truncated_at is initialized

This commit is contained in:
Petr Gusev
2023-09-27 22:35:56 +04:00
parent 59db2703cd
commit 80fa5810a7
2 changed files with 10 additions and 4 deletions

View File

@@ -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<db_clock::time_point> _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();

View File

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