mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-22 07:42:16 +00:00
this change addresses the possible data resurrection after "nodetool compact" and "nodetool flush" commands. and prepare for the fix of a similar data resurrection issue after "nodetool cleanup". active commitlog segments are recycled in the background once they are discarded. and there is a chance that we could have data resurrection even after "nodetool cleanup", because the mutations in commitlog's active segments could change the tables which are supposed to be removed by "nodetool cleanup", so as a solution to address this problem in the pre-tablets era, we force new active segments of commitlog, and flush the involved memtables. since the active segments are discarded in the background, the completion of the "nodetool cleanup" does not guarantee that these mutation won't be applied to memtable when server restarts, if it is killed right away. the same applies to "force_flush", "force_compaction" and "force_keyspace_compaction" API calls which are used by nodetool as well. quote from Benny's comment > If major comapction doesn't wait for the commitlog deletion it is > also exposed to data resurrection since theoretically it could purge > tombstones based on the assumption that commitlog would not resurrect > data that they might shadow, BUT on a crash/restart scenario commitlog > replay would happen since the commitlog segments weren't deleted - > breaking the contract with compaction. so to ensure that the active segments are reclaimed upon completion of "nodetool cleanup", "nodetool compact" and "nodetool flush" commands, let's wait for pending deletes in `database::flush_all_tables()`, so the caller wait until the reclamation of deleted active segments completes. Refs #4734 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com> Closes scylladb/scylladb#16915