From fac2bc41ba4639c7b5a4a45b8fc8f66aa4ae6d4e Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Wed, 3 Aug 2022 10:47:28 +0000 Subject: [PATCH] commitlog: Include "segments_to_replay" in initial footprint Fixes #11184 Not including it here can cause our estimate of "delete or not" after replay to be skewed in favour of retaining segments as (new) recycles (or even flip a counter), and if we have repeated crash+restarts we could be accumulating an effectivly ever increasing segment footprint Closes #11205 --- db/commitlog/commitlog.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index bffd73d006..09bd1986b7 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -1474,6 +1474,11 @@ future<> db::commitlog::segment_manager::init() { for (auto& d : descs) { id = std::max(id, replay_position(d.id).base_id()); _segments_to_replay.push_back(cfg.commit_log_location + "/" + d.filename()); + // #11184 - include replay footprint so we make sure to delete any segments + // pushing us over limits in "delete_segments" (assumed called after replay) + // Note: if noone calls get_segments_to_replay + delete we're rather borked, + // but... + totals.total_size_on_disk += co_await file_size(_segments_to_replay.back()); } // base id counter is [ | ]