[Pipe] Deduplicate historical tsfile events in IoTConsensusV2 pipes#17472
Open
Pengzna wants to merge 7 commits intoapache:masterfrom
Open
[Pipe] Deduplicate historical tsfile events in IoTConsensusV2 pipes#17472Pengzna wants to merge 7 commits intoapache:masterfrom
Pengzna wants to merge 7 commits intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses duplicate tsfile transfer in IoTConsensusV2 “batch mode” pipes by introducing a per-task-instance dedup scope shared between the realtime and historical sources, allowing the historical source to skip tsfiles already captured by the realtime source.
Changes:
- Add a per-task
tsFileDedupScopeIDand use it as the key for tsfile progress index tracking/dedup. - Register realtime-captured tsfiles into a scoped keeper and have the historical source skip duplicates under the same scope.
- Add unit tests covering scoped behavior (contains/check/clear) of the keeper.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/assigner/PipeTsFileEpochProgressIndexKeeper.java | Switch keeper keying from pipeName to task-scope ID; add scoped clear + contains APIs. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/PipeRealtimeDataRegionSource.java | Generate/store task-scope ID and clear scoped keeper state on close; use scope in progress-index checks. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/PipeRealtimeDataRegionTsFileSource.java | Register/eliminate tsfile progress index using the new task-scope ID. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/PipeRealtimeDataRegionHybridSource.java | Register/eliminate tsfile progress index using the new task-scope ID. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/historical/PipeHistoricalDataRegionTsFileAndDeletionSource.java | Compute matching task-scope ID and skip historical tsfile events already captured by realtime under that scope. |
| iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/assigner/PipeTsFileEpochProgressIndexKeeperTest.java | New unit tests verifying the keeper’s scope isolation and scoped clearing. |
Comments suppressed due to low confidence (1)
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/realtime/assigner/PipeTsFileEpochProgressIndexKeeper.java:83
isProgressIndexAfterOrEqualsname doesn’t match its predicate:!resource.getMaxProgressIndex().isAfter(progressIndex)is equivalent tomaxProgressIndex <= progressIndex(i.e., before or equal), not after or equal. This makes the API very easy to misuse. Please either invert the comparison to match the name, or rename the method to reflect the current behavior (and adjust tests/callers accordingly).
public synchronized boolean isProgressIndexAfterOrEquals(
final int dataRegionId,
final String taskScopeID,
final String tsFilePath,
final ProgressIndex progressIndex) {
return progressIndexKeeper
.computeIfAbsent(dataRegionId, k -> new ConcurrentHashMap<>())
.computeIfAbsent(taskScopeID, k -> new ConcurrentHashMap<>())
.entrySet()
.stream()
.filter(entry -> !Objects.equals(entry.getKey(), tsFilePath))
.map(Entry::getValue)
.filter(Objects::nonNull)
.anyMatch(resource -> !resource.getMaxProgressIndex().isAfter(progressIndex));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jt2594838
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
In IoTConsensusV2 batch mode, the same logical tsfile can be observed by both the realtime source and the historical source in the same consensus pipe task. When that happens, the duplicated historical tsfile event may allocate another
replicateIndexfor an already captured file and cause redundant receiver-side seal/retry behavior.What Changed
Verification
mvn -pl iotdb-core/datanode -DskipITs -Dtest=PipeTsFileEpochProgressIndexKeeperTest testmvn clean package -DskipTests -T 1Cdata_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensusV2DEVICE_NUMBER=10,SENSOR_NUMBER=1,BATCH_SIZE_PER_WRITE=100000,LOOP=10iot-benchmark -> flushskip historical tsfile ... because realtime source in current task ... has already captured itwriting file null is not available,Failed to seal file, or2204errors were observed in this repro