Skip to content

Harden LOAD diagnostics and Pipe file integrity - #19395

Open
Caideyipi wants to merge 12 commits into
apache:masterfrom
Caideyipi:codex/load-pipe-integrity-20261125
Open

Caideyipi wants to merge 12 commits into
apache:masterfrom
Caideyipi:codex/load-pipe-integrity-20261125

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve TsFile LOAD parse failure offsets and causes in failure diagnostics.
  • Validate sliced Pipe transfers and retry corrupted slices.
  • Archive failed received files under configured count and size limits.

Example

Loading a truncated broken.tsfile that fails at byte offset 4096 now 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

  • 102 targeted regression tests passed.
  • Full-reactor English and Chinese test-compile passed.
  • PipeTransferIntegrityUtilsTest: 2 tests passed.
  • Cluster-level and integration-test end-to-end scenarios were not run.

private TPipeTransferResp receiveInternal(final TPipeTransferReq req) {
try {
final long startTime = System.nanoTime();
if (req.isSetCrc32()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Caideyipi

Caideyipi commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

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); git diff --check passed. Cluster-level and integration end-to-end scenarios were not run. Revisions: reviewed f03d522ed5752c6a6a2528cd91ca3a6b9e37c22c; final local and confirmed source-branch/PR head b3ded8cf3bded44f65b30c179cabef1a34c89ecf. PR remains open.

private TPipeTransferResp receiveInternal(final TPipeTransferReq req) {
try {
final long startTime = System.nanoTime();
if (req.isSetCrc32() && req.getType() != PipeRequestType.TRANSFER_SLICE.getType()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

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 (execution_observed: false because the runner did not recognize its log marker); 35 targeted DataNode tests passed with 0 failures, errors, or skips; git diff --check passed.

Revisions: reviewed b3ded8cf3bded44f65b30c179cabef1a34c89ecf; final local, source-branch, and PR head d4b6bb052c20959165495ea3a3ee18bb749f0894. PR remains open and non-draft. No discussions were resolved.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Re-review update — Addressed the slice CRC finding. The receiver now validates the CRC of every CRC-enabled request, including each TRANSFER_SLICE frame, before parsing it. On a slice mismatch, it returns the CRC-mismatch file error and clears any buffered slice group. Added receiver coverage that corrupts the second slice after the first was accepted while retaining the advertised CRC.

Verification: Spotless apply exited 0 (the runner did not recognize its apply-goal log marker); mvn clean test -pl iotdb-core/datanode -am -Dtest=IoTDBDataNodeReceiverTest -Dsurefire.failIfNoSpecifiedTests=false passed (28 tests; 0 failures, errors, or skips); git diff HEAD^ HEAD --check passed.

Revisions: reviewed d4b6bb052c20959165495ea3a3ee18bb749f0894; final local and confirmed source-branch/PR head 10b8c008bca29d3452f7378ffdff1b0679c08ba0. PR remains open and non-draft. No discussions were resolved.

@Caideyipi
Caideyipi marked this pull request as draft November 26, 2026 02:41
@Caideyipi

Caideyipi commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review update — At 10b8c008bca29d3452f7378ffdff1b0679c08ba0, initFailDirIfNecessary created the failed-load directory without enforcing its configured size limit. Archives left over from a previous run could remain over the limit until another permanent load failure triggered eviction. Initialization now enforces the limit, retains the newest existing group, and invalidates indexes for evicted groups. Added startup-pruning regression coverage.

Verification: mvn spotless:apply -P with-integration-tests -pl iotdb-core/datanode -am exited 0 and logged BUILD SUCCESS (the runner did not recognize its apply-goal marker); mvn clean test -pl iotdb-core/datanode -am -Dtest=ActiveLoadTsFileLoaderTest -Dsurefire.failIfNoSpecifiedTests=false passed (15 tests, 0 failures, errors, or skips); git diff --check passed.

Revisions: reviewed 10b8c008bca29d3452f7378ffdff1b0679c08ba0; final local and confirmed source-branch/PR head 0573a0268524ff78c7327093819334d9ca616ed2. The PR is now open for review (non-draft). An independent re-review of the updated head has not yet been performed.

@Caideyipi
Caideyipi marked this pull request as ready for review November 26, 2026 03:11
return;
}

if (!enforceFailureDirectoryMaxSize(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@Caideyipi

Copy link
Copy Markdown
Collaborator Author

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++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

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: mvn spotless:apply -P with-integration-tests -pl iotdb-client/service-rpc,iotdb-core/node-commons,iotdb-core/datanode -am passed; the targeted clean test run passed (42 tests, 0 failures, 0 errors, 0 skipped); patch helper tests passed (8/8); git diff --check passed.

Revisions: reviewed ae81deb59081c691be74b4fd2ae8b0174e6bb53b; final local commit and confirmed source-branch/PR head 50ff8067a3eb0e3e158af3598f08a122d55db407. The PR remains open (non-draft). No update steps remain incomplete.

new File(LoadUtil.getTsFileModsV2Path(filePath)));
for (final File file : files) {
if (file.isFile()) {
ActiveLoadTsFileLoader.linkOrCopyFile(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review update — Starting from PR head 8d469d871695ab84c0f1927805703f0b00d2fe69, addressed three actionable findings. Failure archives now use independent copies so CRC retries cannot mutate the diagnostic snapshot. CRC handling now honors the receiver retry/ignore decision and stops/cleans up ignored transfers. Query-parser creation corruption now preserves any known offset and emits the structure-corruption diagnostic even when the offset is unknown. Added regression coverage for all three paths.

Verification: DataNode Spotless apply passed; clean targeted DataNode test passed (1 test); LoadTreeStatementDataTypeConvertExecutionVisitorTest passed (31 tests); targeted Pipe integrity tests passed (40 tests); patch-helper Pester tests passed (8/8); git diff --check passed.

Revision: Final local commit, source branch, and confirmed PR head: b20e22387553f52b22ee735aec61cd45a30dc33c. The PR remains open and non-draft. No discussions were resolved; a fresh independent re-review is required.

&& typeMismatchDetected;
}

static boolean shouldLoadTsFileAsynchronously(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review round summary — Reviewed PR head b20e22387553f52b22ee735aec61cd45a30dc33c; addressed comments 4795348867 and 4795349081. CRC-retry negotiation now preserves the configured async LOAD strategy, and full TsFile SHA-256 diagnostics are computed only when DEBUG logging is enabled.

Verification: DataNode Spotless apply passed; the focused clean DataNode build and tests passed (39 tests, 0 failures, 0 errors, 0 skipped); git diff --check passed. The first local attempt exhausted a 1 GiB Java heap during compilation before running tests; one retry with a 2.5 GiB heap passed. A separate remote test attempt was blocked because a required snapshot dependency could not be fetched (HTTP 403).

Revision: Final local commit, source branch, and confirmed PR head: ebba0c65825c920002b4b37caf7979999ac1aa78. The PR remains open and non-draft. No discussions were resolved; a fresh independent review is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants