Skip to content

Commit fb8599c

Browse files
committed
Remove unproven seek boundary changes from subscription fix
1 parent 4422f4c commit fb8599c

2 files changed

Lines changed: 6 additions & 85 deletions

File tree

‎iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/consensus/ConsensusPrefetchingQueue.java‎

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,7 @@ private ReplayLocateDecision resolveInitReplayStartDecision(
882882
case AT_END:
883883
final long resolvedReplayStartSearchIndex =
884884
replayTarget.getStatus() == ReplayLocateStatus.AT_END
885-
? Math.min(
886-
nextSearchIndexAfter(replayTarget.getStartSearchIndex()),
887-
fallbackTailSearchIndex)
885+
? Math.min(replayTarget.getStartSearchIndex(), fallbackTailSearchIndex)
888886
: replayTarget.getStartSearchIndex();
889887
return new ReplayLocateDecision(
890888
replayTarget.getStatus(),
@@ -2037,6 +2035,7 @@ private void advanceWalReplayCursorIfPresent(final IndexedConsensusRequest reque
20372035
if (!hasLocalSearchIndex(request)) {
20382036
return;
20392037
}
2038+
20402039
final long actualSearchIndex = request.getSearchIndex();
20412040
final long expectedSearchIndex = nextExpectedSearchIndex.get();
20422041
if (actualSearchIndex > expectedSearchIndex) {
@@ -3073,28 +3072,15 @@ public void cleanUp() {
30733072
* old files have been reclaimed, the earliest available position may be later than 0.
30743073
*/
30753074
public void seekToBeginning() {
3076-
final RegionProgress beginningProgress = new RegionProgress(Collections.emptyMap());
3077-
if (consensusReqReader instanceof WALNode) {
3078-
// The first retained WAL index can be greater than one after older files are reclaimed.
3079-
seekToRegionProgress(beginningProgress);
3080-
} else {
3081-
seekToResolvedPosition(FIRST_CONSENSUS_SEARCH_INDEX, beginningProgress, "beginning");
3082-
}
3075+
seekToResolvedPosition(0L, new RegionProgress(Collections.emptyMap()), "beginning");
30833076
}
30843077

30853078
/**
30863079
* Seeks to the current WAL write position. After this, only newly written data will be consumed.
30873080
*/
30883081
public void seekToEnd() {
3089-
final RegionProgress tailProgress = computeTailRegionProgress();
30903082
seekToResolvedPosition(
3091-
nextSearchIndexAfter(consensusReqReader.getCurrentSearchIndex()), tailProgress, "end");
3092-
}
3093-
3094-
private static long nextSearchIndexAfter(final long searchIndex) {
3095-
return searchIndex == Long.MAX_VALUE
3096-
? Long.MAX_VALUE
3097-
: Math.max(FIRST_CONSENSUS_SEARCH_INDEX, searchIndex + 1L);
3083+
consensusReqReader.getCurrentSearchIndex(), computeTailRegionProgress(), "end");
30983084
}
30993085

31003086
public void seekToRegionProgress(final RegionProgress regionProgress) {
@@ -3122,9 +3108,7 @@ public void seekToRegionProgress(final RegionProgress regionProgress) {
31223108
replayTarget.getStatus(),
31233109
replayTarget.getStartSearchIndex());
31243110
seekToResolvedPosition(
3125-
replayTarget.getStatus() == ReplayLocateStatus.AT_END
3126-
? nextSearchIndexAfter(replayTarget.getStartSearchIndex())
3127-
: replayTarget.getStartSearchIndex(),
3111+
replayTarget.getStartSearchIndex(),
31283112
replayTarget.getRecoveryRegionProgress(),
31293113
"regionProgress");
31303114
return;
@@ -3165,9 +3149,7 @@ public void seekAfterRegionProgress(final RegionProgress regionProgress) {
31653149
replayTarget.getStatus(),
31663150
replayTarget.getStartSearchIndex());
31673151
seekToResolvedPosition(
3168-
replayTarget.getStatus() == ReplayLocateStatus.AT_END
3169-
? nextSearchIndexAfter(replayTarget.getStartSearchIndex())
3170-
: replayTarget.getStartSearchIndex(),
3152+
replayTarget.getStartSearchIndex(),
31713153
replayTarget.getRecoveryRegionProgress(),
31723154
"regionProgressAfter");
31733155
return;

‎iotdb-core/datanode/src/test/java/org/apache/iotdb/db/subscription/broker/consensus/ConsensusPrefetchingQueueTest.java‎

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,67 +1210,6 @@ protected ReplayLocateDecision locateReplayStartForRegionProgress(
12101210
}
12111211
}
12121212

1213-
@Test
1214-
public void testAtEndInitializationStartsAfterLastWalIndex() throws Exception {
1215-
final String originalSystemDir = IoTDBDescriptor.getInstance().getConfig().getSystemDir();
1216-
final File systemDir = temporaryFolder.newFolder("atEndAfterTail");
1217-
final File walDirectory = temporaryFolder.newFolder("atEndAfterTailWal");
1218-
ConsensusPrefetchingQueue queue = null;
1219-
try {
1220-
final DataRegionId regionId = new DataRegionId(8);
1221-
final WALNode walNode = mock(WALNode.class);
1222-
when(walNode.getLogDirectory()).thenReturn(walDirectory);
1223-
when(walNode.getCurrentSearchIndex()).thenReturn(4L);
1224-
final IoTConsensusServerImpl serverImpl = mock(IoTConsensusServerImpl.class);
1225-
when(serverImpl.getConsensusReqReader()).thenReturn(walNode);
1226-
when(serverImpl.getWriterSafeFrontierTracker()).thenReturn(new WriterSafeFrontierTracker());
1227-
final ConsensusLogToTabletConverter converter = mock(ConsensusLogToTabletConverter.class);
1228-
when(converter.convert(any())).thenReturn(Collections.singletonList(createTablet()));
1229-
when(converter.getDatabaseName()).thenReturn("db");
1230-
final RegionProgress committedProgress =
1231-
new RegionProgress(
1232-
Collections.singletonMap(
1233-
new WriterId(regionId.toString(), 7), new WriterProgress(1000L, 2L)));
1234-
queue =
1235-
new ConsensusPrefetchingQueue(
1236-
"consumerGroup",
1237-
"topic",
1238-
TopicConstant.ORDER_MODE_LEADER_ONLY_VALUE,
1239-
regionId,
1240-
serverImpl,
1241-
new SubscriptionWalRetentionPolicy(
1242-
"topic",
1243-
SubscriptionWalRetentionPolicy.UNBOUNDED,
1244-
SubscriptionWalRetentionPolicy.UNBOUNDED),
1245-
converter,
1246-
newCommitManager(systemDir),
1247-
committedProgress,
1248-
5L,
1249-
1L,
1250-
true) {
1251-
@Override
1252-
protected ReplayLocateDecision locateReplayStartForRegionProgress(
1253-
final RegionProgress regionProgress, final boolean seekAfter) {
1254-
return ReplayLocateDecision.atEnd(
1255-
walNode.getCurrentSearchIndex(), regionProgress, "empty sealed WAL");
1256-
}
1257-
};
1258-
queue.setSubscriptionMemoryManager(new SubscriptionMemoryManager(16L * 1024 * 1024));
1259-
1260-
assertNull(queue.poll("consumer"));
1261-
assertEquals(5L, queue.getCurrentReadSearchIndex());
1262-
assertTrue(pendingEntries(queue).offer(createRequest(5L)));
1263-
queue.drivePrefetchOnce();
1264-
assertEquals(6L, queue.getCurrentReadSearchIndex());
1265-
assertEquals(1L, queue.getPendingPathAcceptedEntries());
1266-
} finally {
1267-
if (queue != null) {
1268-
queue.close();
1269-
}
1270-
IoTDBDescriptor.getInstance().getConfig().setSystemDir(originalSystemDir);
1271-
}
1272-
}
1273-
12741213
@Test
12751214
public void testZeroPhysicalTimeUsesWriterLocalSequenceForReplayLookup() throws Exception {
12761215
final String originalSystemDir = IoTDBDescriptor.getInstance().getConfig().getSystemDir();

0 commit comments

Comments
 (0)