diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java index 09a60ee5c0b..31619c5daa2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java @@ -676,8 +676,10 @@ private void testMergeViewIndexSequencesHelper(boolean isNamespaceMappingEnabled afterUpgradeAllocations.add(new SequenceAllocation(sequenceUpgrade, 1)); long[] afterUpgradeValues = new long[1]; SQLException[] afterUpgradeExceptions = new SQLException[1]; - cqs.incrementSequences(afterUpgradeAllocations, EnvironmentEdgeManager.currentTimeMillis(), - afterUpgradeValues, afterUpgradeExceptions); + // The merge can create the new sequence in the current millisecond. + // A read at the latest timestamp sees that row, as NEXT VALUE FOR does without an SCN. + cqs.incrementSequences(afterUpgradeAllocations, HConstants.LATEST_TIMESTAMP, afterUpgradeValues, + afterUpgradeExceptions); assertNull(afterUpgradeExceptions[0]); int safetyIncrement = 100; @@ -697,8 +699,10 @@ private SequenceKey createViewIndexSequenceWithOldName(ConnectionQueryServices c MetaDataUtil.getOldViewIndexSequenceKey(tenantId, viewIndexTable, 0, isNamespaceMapped); // Sequences are owned globally even if they contain a tenantId in the name String sequenceTenantId = isNamespaceMapped ? tenantId : null; + // A sequence read sees only cells older than the read timestamp. + // Create the legacy sequence one millisecond in the past, so that each later read sees it. cqs.createSequence(sequenceTenantId, key.getSchemaName(), key.getSequenceName(), Long.MIN_VALUE, - 1, 1, Long.MIN_VALUE, Long.MAX_VALUE, false, EnvironmentEdgeManager.currentTimeMillis()); + 1, 1, Long.MIN_VALUE, Long.MAX_VALUE, false, EnvironmentEdgeManager.currentTimeMillis() - 1); return key; }