diff --git a/memtable.hh b/memtable.hh index 3a78c734f7..5752880408 100644 --- a/memtable.hh +++ b/memtable.hh @@ -272,8 +272,8 @@ public: const db::replay_position& replay_position() const { return _replay_position; } - const db::rp_set& rp_set() const { - return _rp_set; + db::rp_set rp_set() { + return std::exchange(_rp_set, {}); } friend class iterator_reader; diff --git a/table.cc b/table.cc index b801c4a9ea..7a9ae7f41f 100644 --- a/table.cc +++ b/table.cc @@ -1504,7 +1504,9 @@ bool table::can_flush() const { future<> table::clear() { _memtables->clear_and_add(); if (_commitlog) { - _commitlog->discard_completed_segments(_schema->id()); + for (auto& t : *_memtables) { + _commitlog->discard_completed_segments(_schema->id(), t->rp_set()); + } } return _cache.invalidate(row_cache::external_updater([] { /* There is no underlying mutation source */ })); }