mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 08:30:35 +00:00
The commitlog replayer groups segments by shard using a std::unordered_multimap, then iterates per-shard segments via equal_range(). However, equal_range() does not guarantee iteration order for elements with the same key, so segments could be replayed out of order within a shard. This can increase memory and disk consumption during fragmented entry reconstruction, which accumulates fragments across segments and benefits from ascending ID order. This is also required by the strongly consistent tables feature, particularly commitlog-based storage that relies on replayed raft items being stored in order. Fix by changing the data structure from std::unordered_multimap<unsigned, commitlog::descriptor> to std::unordered_map<unsigned, utils::chunked_vector<commitlog::descriptor>> Since the descriptors are inserted from a std::set ordered by ID, the vector preserves insertion (and thus ID) order. The per-shard iteration now simply iterates the vector, guaranteeing correct replay order. Fixes SCYLLADB-1411.