Repository navigation
Conversation
| private TPipeTransferResp receiveInternal(final TPipeTransferReq req) { | ||
| try { | ||
| final long startTime = System.nanoTime(); | ||
| if (req.isSetCrc32()) { |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:281 — CRC check rejects every CRC-enabled sliced transfer
PipeTransferSliceReqBuilder.buildSliceReq sets the slice CRC over the slice frame (version/type/TRANSFER_SLICE body), but receiveInternal validates req.getCrc32() against calculateCrc32(req) before the type switch, so a TRANSFER_SLICE frame always mismatches and returns PIPE_TRANSFER_FILE_ERROR. After the first structural-corruption retry enables crcEnabled, any TsFile piece above pipeSinkRequestSliceThresholdBytes can never be transferred.
Fix: Skip the CRC check for PipeRequestType.TRANSFER_SLICE (the assembled request is re-validated in PipeTransferSliceReqHandler.makeReqIfComplete), or validate the slice CRC against the slice body only.
There was a problem hiding this comment.
Fixed in b3ded8cf3bd: CRC validation now skips TRANSFER_SLICE envelopes so CRC-enabled slices can be assembled and the completed request follows the existing receive path. Added regression coverage for a CRC-enabled multi-slice request.
| continue; | ||
| } | ||
| totalSize -= getDirectorySize(group); | ||
| FileUtils.deleteDirectory(group); |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java:553 — Size cap deletes failure groups still referenced by the failed-file index
enforceFailureDirectoryMaxSize deletes the oldest active-load-* groups, but failedFileSnapshots and indexedFailDir are not invalidated. isFilePendingOrLoading then keeps returning true for a source TsFile whose published group was deleted, so the still-present file is never re-enqueued and is silently skipped by the active loader.
Fix: After deleting a group, drop the matching failedFileSnapshots entries (and reset indexedFailDir) so the source file becomes eligible for loading again.
There was a problem hiding this comment.
Fixed in b3ded8cf3bd: evicting a failure group now removes snapshots tied to it, clears their source paths from the failed-file set, and invalidates the index for the next scan. Added regression coverage confirming the source becomes eligible for loading after its archive is pruned.
|
Review update — Addressed both findings: CRC-enabled sliced requests reach assembly, and size-cap eviction clears stale active-load failure-index entries. Regression coverage was added for both paths. Verification: Spotless apply exited 0 (the runner did not recognize the apply-goal marker); 40 targeted DataNode tests passed (0 failures, errors, or skips); |
| private TPipeTransferResp receiveInternal(final TPipeTransferReq req) { | ||
| try { | ||
| final long startTime = System.nanoTime(); | ||
| if (req.isSetCrc32() && req.getType() != PipeRequestType.TRANSFER_SLICE.getType()) { |
There was a problem hiding this comment.
critical iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:281 — CRC pre-check rejects every CRC-enabled compressed transfer
PipeTransferCompressedReq.toTPipeTransferReq recomputes the CRC over the compressed frame (version/TRANSFER_COMPRESSED/compressed body), but receiveInternal validates it against calculateCrc32(req) of that same frame before decompression, while the sender's CRC covers the uncompressed request. With sink compression enabled every CRC-enabled request (the whole retry path) fails with PIPE_TRANSFER_FILE_ERROR CRC mismatch and can never be loaded.
Fix: Skip the pre-dispatch CRC check for TRANSFER_COMPRESSED (like TRANSFER_SLICE) and validate the CRC on the decompressed request inside the TRANSFER_COMPRESSED branch, or carry the original CRC through the compressed frame.
There was a problem hiding this comment.
Thanks for the report. I traced the request lifecycle and could not reproduce the mismatch: when the original request has a CRC, PipeTransferCompressedReq.toTPipeTransferReq recalculates it over the compressed frame, which is the same frame checked by receiveInternal before decompression. The decoded nested request then receives its own CRC before nested dispatch. I added receiver coverage for a CRC-enabled compressed request and for a modified compressed body; the valid request reaches dispatch, while the modified frame is rejected before dispatch. No receiver logic change was needed.
| final TSStatus status = response.getStatus(); | ||
| if (PipeTransferIntegrityUtils.isStructureCorruption(status.getMessage())) { | ||
| logReceiverReportedStructureCorruption(status); | ||
| if (!crcRetryAttempted) { |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/async/handler/PipeTransferTsFileHandler.java:345 — Structure-corruption retry restarts transfer with a stale reader offset
On a structure-corruption seal response the handler resets position=0, transferringModFile/transferringTsFile=false and calls transfer(), but reader is still open and positioned at EOF. readNextFilePiece returns -1, openNextFile() returns false, and the seal is re-sent immediately without retransmitting any piece, so the receiver reports a length mismatch and the CRC retry never re-sends the file.
Fix: Close and null the reader (and reset effectiveTransferMod/currentFile) before calling transfer() so openNextFile() reopens the file at offset 0.
There was a problem hiding this comment.
Fixed in d4b6bb0: the structural-corruption retry closes and clears the exhausted reader before resetting transfer progress, so the next transfer reopens the selected file at offset zero. The current file selection and mod-transfer state are retained/reset by the existing retry logic. Added regression coverage that verifies the old reader is closed and the retry reopens from the beginning.
|
Review update — Addressed both new comments. The compressed-transfer CRC report was not reproducible: the sender recalculates CRC over the compressed frame and the receiver validates that frame before decompression. Added coverage for a CRC-enabled compressed request and rejection of a modified frame; no receiver logic change was needed. The structure-corruption retry now closes and clears the exhausted TsFile reader before restarting, with regression coverage confirming the file reopens at offset zero. Verification: Spotless apply exited 0 ( Revisions: reviewed |
|
Re-review update — Addressed the slice CRC finding. The receiver now validates the CRC of every CRC-enabled request, including each Verification: Spotless apply exited 0 (the runner did not recognize its apply-goal log marker); Revisions: reviewed |
|
Review update — At Verification: Revisions: reviewed |
| return; | ||
| } | ||
|
|
||
| if (!enforceFailureDirectoryMaxSize( |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java:528 — Size cap can delete the just-published failure group and then skip source cleanup
enforceFailureDirectoryMaxSize keeps newestGroup only while it is still a directory. When the new group alone exceeds the cap and an older group exists, the loop deletes every other group, then returns false because totalSize > maxSize and groupToKeep.isDirectory() is false. removeFileAndResourceAndModsToFailDirUnderLock then returns before deletePublishedSourceFiles, so the failed TsFile stays in the listening dir and is re-loaded on every scan while its archive is gone.
Fix: Do not treat an over-cap newest group as a failure: return true once only the newest group remains (or when the newest group exists), and only return false on real I/O errors.
There was a problem hiding this comment.
Fixed. The newest published group is retained even when it alone exceeds the configured cap, so pruning older groups is not treated as a failed publication. That allows source cleanup to proceed. I added end-to-end coverage asserting that the TsFile and sidecars are removed after the oversized archive is published.
| @Override | ||
| protected boolean onFileStructureLoadFailure( | ||
| final List<String> fileAbsolutePaths, final TSStatus status) { | ||
| synchronized (ActiveLoadTsFileLoader.class) { |
There was a problem hiding this comment.
minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:981 — Structure-corruption archive bypasses the failure-directory lock used by ActiveLoadTsFileLoader
onFileStructureLoadFailure synchronizes on ActiveLoadTsFileLoader.class, but ActiveLoadTsFileLoader now guards publication/eviction with the private FAILURE_DIRECTORY_LOCK object. A concurrent active-load failure can therefore run enforceFailureDirectoryMaxSize while archiveStructureCorruptedFiles is copying into the same fail dir, so the new pipe-structure-* group can be evicted mid-copy or the size accounting can be computed from a partially written group.
Fix: Expose the same lock (e.g. a public static lock object or a static helper on ActiveLoadTsFileLoader) and use it in both publication and archive paths.
There was a problem hiding this comment.
Addressed. Both paths synchronize on the same monitor: FAILURE_DIRECTORY_LOCK aliases ActiveLoadTsFileLoader.class, which onFileStructureLoadFailure also uses. Eviction therefore cannot race with structure-corruption archive publication.
…load-pipe-integrity-20261125 # Conflicts: # iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTreeTsFileTabletIterator.java
|
Review round summary — review input PR head 0573a02; final local commit and confirmed source branch/PR head ae81deb. Synced master at cfa607e with merge commit a7aebef. Addressed feedback on independent archive copies and size accounting, whole-group retransmission, corruption identification, failure-directory scans, safe file truncation, oversized newest-group cleanup, and shared locking. Added regression coverage for truncate/retry behavior and source cleanup after publishing an oversized newest archive. Verification: Spotless completed; clean targeted Maven run passed (125 tests, 0 failures, 0 errors, 0 skipped). No update steps remain incomplete. All eight inline discussions have replies and remain unresolved. |
| final boolean transferMod = | ||
| Objects.nonNull(modFile) && clientManager.supportModsIfIsDataNodeReceiver(); | ||
| TPipeTransferResp resp = null; | ||
| for (int attempt = 0; attempt < 2; attempt++) { |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/sync/IoTDBDataRegionSyncSink.java:585 — Sync sink CRC retry re-sends pieces from offset 0 without resetting receiver state
On a structure-corruption seal response the loop re-runs transferFilePieces for the mod file and the TsFile with crcEnabled=true. The receiver only truncates when req.isSetCrc32() && startWritingOffset == 0 (IoTDBFileReceiver:510), but the seal failure path already deleted the sealed file and the receiver's writingFile is null, so the first piece at offset 0 creates a fresh file — while the mod file, which was fully written before the seal, is re-sent from offset 0 and the receiver returns PIP
…[truncated]
Fix: Only re-transfer the TsFile on the retry (skip the mod file when it was already accepted), or reset the receiver's writing file explicitly before re-sending pieces.
There was a problem hiding this comment.
I checked both receiver paths. A successful structure-failure archive is followed by cleanup of the V2 staging directory, including the mod file, so retrying the full file group is necessary. If archiving fails and staging is preserved, a CRC-enabled piece at offset zero truncates an existing file before rewriting it. I added regression coverage for the mod-file reset; no sink change was needed.
| if (directories == null) { | ||
| return false; | ||
| } | ||
| if (directories.length <= 1) { |
There was a problem hiding this comment.
minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java:559 — Single oversized failure group is reported as success while the archive path reports failure
When directories.length <= 1 the method returns newestGroup == null || newestGroup.isDirectory(), i.e. true even if that single group exceeds maxSize, so removeFileAndResourceAndModsToFailDir proceeds to delete the source files. The receiver's archiveStructureCorruptedFiles treats the same condition as a failure and returns false, leaving the sealed file in place. The two callers of the same helper therefore disagree on whether the cap was honoured.
Fix: Return a consistent result for the single-oversized-group case (e.g. always true because the newest group is intentionally retained) and document it, so both callers behave identically.
There was a problem hiding this comment.
Both call paths use the same pruning helper. With one oversized group, it returns success only while the newly published group still exists; that is the same policy used for normal load archives and Pipe structural-failure archives. Added regression coverage for the single-group case.
|
Review update — Addressed the remaining review feedback. Added a dedicated structural-corruption status code while preserving message-marker compatibility, and made failure archives use hard links with a copy fallback. Added regression coverage for a single oversized group and CRC retry truncation of an existing mod file. The sync retry already safely retransmits the full group, and both archive paths already use the same size-limit result; I left those behaviors unchanged and explained why the newest group remains protected. Verification: Revisions: reviewed |
| new File(LoadUtil.getTsFileModsV2Path(filePath))); | ||
| for (final File file : files) { | ||
| if (file.isFile()) { | ||
| ActiveLoadTsFileLoader.linkOrCopyFile( |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:1011 — Hard-linked failure archive is mutated by the receiver's CRC retry
archiveStructureCorruptedFiles hard-links the sealed TsFile and sidecars (linkOrCopyFile). With a conversion task id (sink async-load-on-type-mismatch), a corruption failure makes markRetryable set PAUSED, so shouldDeleteSealedFilesOnFailure keeps the sealed files; the sender's CRC retry then resends piece 0, and handleTransferFilePiece truncates that same inode to 0 (IoTDBFileReceiver:510) and rewrites it, so the archive no longer holds the bytes that failed validation.
Fix: Snapshot with a real copy when the receiver's sealed file may be retained (or archive after the receiver's copy is removed), so a retried transfer cannot mutate the archived group.
There was a problem hiding this comment.
Fixed: structural-failure archives now copy the sealed TsFile and sidecars into independent files. A CRC retry can truncate and rewrite the receiver files without changing the archived bytes. Added a regression test that rewrites the receiver file and verifies the archive remains independent and unchanged.
| } | ||
| if (PipeTransferIntegrityUtils.isCrcMismatch(status.getMessage())) { | ||
| logCrcMismatch(status); | ||
| sink.statusHandler().handle(status, status.getMessage(), tsFile.getName()); |
There was a problem hiding this comment.
minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/async/handler/PipeTransferTsFileHandler.java:363 — CRC-mismatch branch throws after statusHandler().handle(), discarding its ignore decision
PipeReceiverStatusHandler.handle is documented as "do nothing if ignoring the event, throw if retrying", and handleOtherExceptions returns normally once the configured others-retry budget expires (resetting the budget). The new CRC-mismatch branches call handle(...) and then unconditionally throw PipeException, so the ignore/record-ignored-data decision never takes effect and a persistently corrupted transfer is retried forever. Same pattern at line 432 and IoTDBDataRegionSyncSink:609/828.
Fix: Only throw when handle() itself throws; otherwise return and let the handler's decision (ignore/stop) stand, as the pre-existing failure branches do.
There was a problem hiding this comment.
Fixed: CRC-mismatch handling now follows the decision made by PipeReceiverStatusHandler.handle. If it returns normally to ignore the failure, the async sender stops and cleans up without queuing a retry, and the sync sender stops the file-piece transfer without sealing. Added regression coverage for the ignored async and sync transfer paths.
…pr19395-sync-master # Conflicts: # iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodePipeMessages.java # iotdb-core/datanode/src/main/i18n/zh/org/apache/iotdb/db/i18n/DataNodePipeMessages.java
| verifyQueryFallbackMeasurements(); | ||
| close(); | ||
| if (Objects.nonNull(unrecoverableQueryFailure)) { | ||
| if (unrecoverableCorruptionOffset >= 0 |
There was a problem hiding this comment.
minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/converter/LoadTreeTsFileTabletIterator.java:979 — Query-parser-creation corruption never produces the structure-corruption marker/offset
When the scan parser hits a truncated chunk it sets unrecoverableCorruptionOffset and falls back to query parsing; if a per-device query parser cannot be created (activateNextQueryParser catch calls splitOrSkipActiveQueryTask with activeQueryParser == null), queryFailureOffset is -1 and line 1044 overwrites unrecoverableCorruptionOffset with -1. finishIteration (line 979) only builds the diagnostic when the offset is >= 0, so it throws the generic IllegalStateException (toRuntimeException of the EOF has no marker). The receiver/sender therefore treat it as an ordinary load error and the CRC retry never fires, and the offset/SHA diagnostic is lost.
Fix: Emit the structure-corruption diagnostic whenever isStructureCorruption(unrecoverableQueryFailure) is true (createDiagnosticMessage already supports offset -1 as unknown), and only overwrite unrecoverableCorruptionOffset when queryFailureOffset >= 0.
There was a problem hiding this comment.
Fixed: structure-corruption diagnostics are now emitted even when the offset is unknown, and a query-parser creation failure only replaces the scan-corruption offset when it provides a nonnegative offset. Added a regression test verifying that the scan offset and diagnostic marker survive an EOF during query-parser creation.
|
Review update — Starting from PR head Verification: DataNode Spotless apply passed; clean targeted DataNode test passed (1 test); Revision: Final local commit, source branch, and confirmed PR head: |
| && typeMismatchDetected; | ||
| } | ||
|
|
||
| static boolean shouldLoadTsFileAsynchronously( |
There was a problem hiding this comment.
major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java:908 — Negotiated crcRetry flag silently disables the configured async LOAD strategy
Both client managers now unconditionally send HANDSHAKE_KEY_CRC_RETRY=true, so supportsCrcRetry is true for any upgraded sender and shouldLoadTsFileAsynchronously(usingAsync, true) returns false. A receiver whose pipe is configured with sink.load-tsfile-strategy=async therefore stops using loadTsFileAsync and runs the whole LOAD inline in the seal RPC; large TsFiles exceed the transfer timeout and stall the pipe.
Fix: Keep honoring the negotiated strategy (an async load can simply skip the CRC retry), or only force sync when the sender's strategy is sync, instead of overriding async whenever supportsCrcRetry is advertised.
There was a problem hiding this comment.
Fixed in ebba0c65825c920002b4b37caf7979999ac1aa78. CRC-retry negotiation no longer overrides the receiver's configured async LOAD strategy; both V1 and V2 paths now dispatch according to that strategy. Updated the regression test to assert the configured async decision is preserved. The focused DataNode build and tests passed (39 tests, 0 failures or errors).
| DataNodePipeMessages | ||
| .LOG_RECEIVER_REPORTED_STRUCTURAL_CORRUPTION_IN_TSFILE_ARG_SENDER_SHA_256_ARG_RECEIVER_STATUS_ARG_026A14BB, | ||
| tsFile, | ||
| PipeTransferIntegrityUtils.calculateSha256OrUnavailable( |
There was a problem hiding this comment.
minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/thrift/async/handler/PipeTransferTsFileHandler.java:427 — Full TsFile SHA-256 computed inside the async client completion callback thread
logReceiverReportedStructureCorruption and logCrcMismatch call calculateSha256OrUnavailable(tsFile), which streams the whole TsFile, from onCompleteInternal, i.e. the Thrift/Netty callback thread of the pooled async client. For a multi-GB TsFile this blocks that event-loop thread for seconds on every corruption/CRC report, delaying completions of other pipe transfers sharing the client and risking transfer timeouts.
Fix: Compute the hash outside the callback thread (executor/queue) or only when the corresponding log level is enabled, so failure logging cannot stall the client's I/O thread.
There was a problem hiding this comment.
Fixed in ebba0c65825c920002b4b37caf7979999ac1aa78. Full-file SHA-256 diagnostics are now computed only when DEBUG logging is enabled; normal logging uses the existing unknown marker, avoiding whole-file reads on async completion callbacks. The focused DataNode build and tests passed (39 tests, 0 failures or errors).
|
Review round summary — Reviewed PR head Verification: DataNode Spotless apply passed; the focused clean DataNode build and tests passed (39 tests, 0 failures, 0 errors, 0 skipped); Revision: Final local commit, source branch, and confirmed PR head: |
Summary
Example
Loading a truncated
broken.tsfilethat fails at byte offset4096now retains that offset and the parser cause instead of collapsing to a generic load error. During Pipe transfer, a slice with a CRC mismatch follows the retry path; if transfer remains irrecoverable, the receiver archives the failed file under the configured limits.Verification
test-compilepassed.PipeTransferIntegrityUtilsTest: 2 tests passed.