diff --git a/mutation_partition.hh b/mutation_partition.hh index e9db79c9ed..5b12345ba7 100644 --- a/mutation_partition.hh +++ b/mutation_partition.hh @@ -826,6 +826,7 @@ public: void apply(tombstone deleted_at) { _deleted_at.apply(deleted_at); + maybe_shadow(); } void apply(shadowable_tombstone deleted_at) { diff --git a/test/boost/mutation_test.cc b/test/boost/mutation_test.cc index e7b47b8762..30ee4e2112 100644 --- a/test/boost/mutation_test.cc +++ b/test/boost/mutation_test.cc @@ -1852,6 +1852,29 @@ SEASTAR_TEST_CASE(test_continuity_merging_of_complete_mutations) { return make_ready_future<>(); } +SEASTAR_TEST_CASE(test_commutativity_and_associativity) { + random_mutation_generator gen(random_mutation_generator::generate_counters::no); + gen.set_key_cardinality(7); + + for (int i = 0; i < 10; ++i) { + mutation m1 = gen(); + m1.partition().make_fully_continuous(); + mutation m2 = gen(); + m2.partition().make_fully_continuous(); + mutation m3 = gen(); + m3.partition().make_fully_continuous(); + + assert_that(m1 + m2 + m3) + .is_equal_to(m1 + m3 + m2) + .is_equal_to(m2 + m1 + m3) + .is_equal_to(m2 + m3 + m1) + .is_equal_to(m3 + m1 + m2) + .is_equal_to(m3 + m2 + m1); + } + + return make_ready_future<>(); +} + SEASTAR_TEST_CASE(test_continuity_merging) { return seastar::async([] { simple_schema table; diff --git a/test/lib/mutation_source_test.cc b/test/lib/mutation_source_test.cc index 1b5c4d6e3e..bc6b9bc9eb 100644 --- a/test/lib/mutation_source_test.cc +++ b/test/lib/mutation_source_test.cc @@ -2247,6 +2247,11 @@ public: if (_not_dummy_dist(_gen)) { deletable_row& row = m.partition().clustered_row(*_schema, ckey, is_dummy::no, continuous); row.apply(random_row_marker()); + if (!row.marker().is_missing() && !row.marker().is_live()) { + // Mutations are not associative if dead marker is not matched with a dead row + // due to shadowable tombstone merging rules. See #11307. + row.apply(tombstone(row.marker().timestamp(), row.marker().deletion_time())); + } if (_bool_dist(_gen)) { set_random_cells(row.cells(), column_kind::regular_column); } else {