This is an automated email from the ASF dual-hosted git repository.
palashc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new e317e29024 PHOENIX-7833 CDCBaseIT/CDCQueryIT keep manual edge
installed after applyMutations (#2450)
e317e29024 is described below
commit e317e2902460727372027e0b841a9b7bd0ba6ca0
Author: Andrew Purtell <[email protected]>
AuthorDate: Fri Jul 17 10:13:21 2026 -0700
PHOENIX-7833 CDCBaseIT/CDCQueryIT keep manual edge installed after
applyMutations (#2450)
---
.../it/java/org/apache/phoenix/end2end/CDCBaseIT.java | 19 ++++++++++++++++++-
.../java/org/apache/phoenix/end2end/CDCQueryIT.java | 9 +++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCBaseIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCBaseIT.java
index af33d4d8bc..9fbb38471d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCBaseIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCBaseIT.java
@@ -396,15 +396,25 @@ public class CDCBaseIT extends ParallelStatsDisabledIT {
String datatableName, String tid, List<Set<ChangeRow>> batches, String
cdcName)
throws Exception {
EnvironmentEdgeManager.injectEdge(injectEdge);
+ long latestChangeTS = injectEdge.currentTime();
try (Connection conn = committer.getConnection(tid)) {
for (Set<ChangeRow> batch : batches) {
for (ChangeRow changeRow : batch) {
addChange(conn, tableName, changeRow);
+ if (changeRow.changeTS > latestChangeTS) {
+ latestChangeTS = changeRow.changeTS;
+ }
}
committer.commit(conn);
}
}
- committer.reset();
+ // Keep the manual edge installed for the remainder of the test so
+ // EnvironmentEdgeManager.currentTimeMillis() does not silently revert
+ // to the wall clock and trip QueryCompiler.verifySCN against the
+ // configured max-lookback age. Pin to the latest changeTS so SCN-bounded
+ // reads of the just-applied mutations remain in-window. Per-test
+ // cleanup is the responsibility of the suite's @After hook.
+ injectEdge.setValue(latestChangeTS);
// For debug: uncomment to see the exact HBase cells.
dumpCells(schemaName, tableName, datatableName, cdcName);
@@ -1116,6 +1126,13 @@ public class CDCBaseIT extends ParallelStatsDisabledIT {
EnvironmentEdgeManager.injectEdge(injectEdge);
}
+ /**
+ * Uninstall the manual time edge. Callers should NOT invoke this from
inside test bodies that
+ * still need to issue SCN-bounded reads of the just-applied mutations:
doing so reverts
+ * {@link EnvironmentEdgeManager#currentTimeMillis()} to the wall clock
and may push the SCN
+ * outside the configured max-lookback window. Per-test cleanup belongs in
an {@code @After}
+ * hook instead (see {@code CDCQueryIT#afterTest}).
+ */
public void reset() {
EnvironmentEdgeManager.reset();
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCQueryIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCQueryIT.java
index 69a90faa3e..0076ee171f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CDCQueryIT.java
@@ -70,6 +70,7 @@ import org.apache.phoenix.util.QueryUtil;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.SchemaUtil;
import org.apache.phoenix.util.TestUtil;
+import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -145,6 +146,14 @@ public class CDCQueryIT extends CDCBaseIT {
injectEdge.setValue(EnvironmentEdgeManager.currentTimeMillis());
}
+ @After
+ public void afterTest() {
+ // CDCBaseIT.applyMutations intentionally leaves the manual edge installed
so
+ // SCN-bounded reads in the test body remain inside the max-lookback
window.
+ // Restore the real clock here so per-test isolation is preserved.
+ EnvironmentEdgeManager.reset();
+ }
+
private void cdcIndexShouldNotBeUsedForDataTableQueries(Connection conn,
String dataTableName,
String cdcName) throws Exception {
ResultSet rs = conn.createStatement().executeQuery(