From 98d58400784412d1855997ab7279c9f7722cd7a2 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Wed, 25 Nov 2026 11:25:19 -0800 Subject: [PATCH] PHOENIX-8107 SCNIT.testSCNWithTTL has no timing margin The test sets the SCN one second before the clock read that follows its sleep. TTL masking is evaluated at the SCN. A row expires only when its timestamp is older than the SCN minus the TTL. The old sleep of TTL plus one second therefore gives no margin. The test fails when the commit, the sleep and the clock read all fall in the same milliseconds. Wall-clock slew during the sleep can also cause the failure. Sleep two seconds longer than the TTL. The rows then expire at the SCN with one second of margin. The test still queries at a past SCN. Related: PHOENIX-6888 Co-Authored-By: Claude Opus 5.5 --- .../src/it/java/org/apache/phoenix/end2end/SCNIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java index 767a1658bcb..566aed916a9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java @@ -87,8 +87,9 @@ public void testReadBeforeDelete() throws Exception { public void testSCNWithTTL() throws Exception { int ttl = 2; String fullTableName = createTableWithTTL(ttl); - // sleep for one second longer than ttl - Thread.sleep(ttl * 1000 + 1000); + // The SCN is one second before the current time. Sleep two seconds longer than the TTL so + // that the rows expire at the SCN with one second of margin. + Thread.sleep(ttl * 1000 + 2000); Properties props = new Properties(); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(EnvironmentEdgeManager.currentTime() - 1000));