From 04febb75f10218f0ce6e559f9e40a27ad6705944 Mon Sep 17 00:00:00 2001 From: Stefan Miklosovic Date: Wed, 22 Apr 2026 19:38:17 +0200 Subject: [PATCH] Fix flaky CompactionTaskTest.testFullyExpiredSSTablesAreNotReleasedPrematurely This fix was taken from https://github.com/datastax/cassandra/commit/e397aa06b15f477d027e38129c9bf218e8f0c6a1#diff-3dbddb89a91055a1394ad89dcca2cd4506f01e40b7d73cb38fb0b0413fb0611a patch by Stefan Miklosovic; reviewed by Brandon Williams for CASSANDRA-21329 --- .../cassandra/db/compaction/CompactionTaskTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionTaskTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionTaskTest.java index 1721ffa2ac..f607822236 100644 --- a/test/unit/org/apache/cassandra/db/compaction/CompactionTaskTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/CompactionTaskTest.java @@ -158,10 +158,14 @@ public class CompactionTaskTest gcGraceCfs.forceBlockingFlush(); // SSTable 4 (not fully expired - col3 has longer TTL) + // col3 must have a higher timestamp than SSTable 3's col3 (ts 7) so it is not + // shadowed during compaction. col2's timestamp must stay <= 7 so that SSTable 4's + // minTimestamp remains <= SSTable 3's maxTimestamp, preventing SSTable 3 from being + // detected as fully expired. for (int k = 0; k < numKeys; k++) { - QueryProcessor.executeInternal("INSERT INTO ks.tbl2 (k, col3, data) VALUES (?, 1, ?) USING TIMESTAMP 6 AND TTL 3", k, data); - QueryProcessor.executeInternal("INSERT INTO ks.tbl2 (k, col2, data) VALUES (?, 1, ?) USING TIMESTAMP 8 AND TTL 1", k, data); + QueryProcessor.executeInternal("INSERT INTO ks.tbl2 (k, col3, data) VALUES (?, 1, ?) USING TIMESTAMP 8 AND TTL 3", k, data); + QueryProcessor.executeInternal("INSERT INTO ks.tbl2 (k, col2, data) VALUES (?, 1, ?) USING TIMESTAMP 6 AND TTL 1", k, data); } gcGraceCfs.forceBlockingFlush();