commitlog: Flush all segments if we only have one.

Handle test cases with borked config so we don't deadlock
in cases where we only have one segment in a commitlog
This commit is contained in:
Calle Wilund
2021-05-24 13:41:45 +00:00
parent 8ce836209b
commit bf0a91b566

View File

@@ -1385,7 +1385,8 @@ void db::commitlog::segment_manager::flush_segments(uint64_t size_to_remove) {
// Now get a set of used CF ids:
std::unordered_set<cf_id_type> ids;
std::for_each(_segments.begin(), _segments.end() - 1, [&ids](sseg_ptr& s) {
auto e = std::find_if(_segments.begin(), _segments.end(), std::mem_fn(&segment::is_still_allocating));
std::for_each(_segments.begin(), e, [&ids](sseg_ptr& s) {
for (auto& id : s->_cf_dirty | boost::adaptors::map_keys) {
ids.insert(id);
}