Skip to content

Improve LOAD progress logging - #19502

Open
luoluoyuyu wants to merge 3 commits into
apache:masterfrom
luoluoyuyu:feat/load-progress-logging
Open

luoluoyuyu wants to merge 3 commits into
apache:masterfrom
luoluoyuyu:feat/load-progress-logging

Conversation

@luoluoyuyu

@luoluoyuyu luoluoyuyu commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

LOAD logs one INFO line per analyzed/loaded TsFile today, which floods the log for a file list with thousands of files, while the split/dispatch stage of a file has no progress at all. This PR separates the log levels by audience and adds the missing stages.

  • INFO (whole file list): start, ten-percent progress and summary of the analysis stage and of the loading stage, including total file count, total bytes, byte percentage, average throughput and ETA.
  • INFO (active file): the split, dispatch and commit of the file being loaded emit a throttled heartbeat at most once per 10 s, so a single large file is not silent until it finishes.
  • DEBUG (per file / per piece): the analysis and loading of each TsFile with its cost, the parse progress and dispatch progress of each source TsFile, and the staging of each piece on the receiving region.
  • Debug messages are only built when DEBUG is enabled. Overall progress uses LoadProgressLog: ten buckets, plus a report at least every 10 s inside one bucket, so a large file neither floods the log nor hides a stall.
  • The loading-stage summary groups the failed files by reason, so a batch with failures still reports which causes dominated.

Example

Before, a 3-file LOAD emitted one INFO line per file (and one model line per file), with no overall progress:

INFO ... Load - Analysis Stage: 1/3 tsfiles have been analyzed, progress: 33.333%
INFO ... TsFile /data/a.tsfile is a tree-model file.
INFO ... Load - Analysis Stage: 2/3 tsfiles have been analyzed, progress: 66.667%
...

After, the core progress is aggregated at INFO and reports the byte percentage, throughput and ETA:

INFO ... Load - Analysis Stage: analyzing 3 tsfiles (314572800 bytes in total).
INFO ... Load - Analysis Stage: 1/3 tsfiles have been analyzed, progress: 33.33% (249.37 MB/s, ETA 1s).
INFO ... Load - Analysis Stage: 3/3 tsfiles have been analyzed, progress: 100.00% (249.17 MB/s, ETA 0s).
INFO ... Load - Analysis Stage: finished, 3 tsfiles (314572800 bytes) analyzed in 1204 ms, 249.17 MB/s.
INFO ... Load - Loading Stage: loading 3 tsfiles (314572800 bytes in total).
INFO ... Load - Loading Stage: 1/3 tsfiles have been loaded, progress: 33.33% (36.10 MB/s, ETA 6s).
INFO ... Load - Loading Stage: finished, 3/3 tsfiles loaded in 8310 ms, 36.10 MB/s, 0 failed.

For a single large file, the active file also reports throttled INFO heartbeats while it is split, dispatched and committed:

INFO ... Load - Split Stage: tsfile /data/a.tsfile parsed 157286400/314572800 bytes, progress: 50.00%.
INFO ... Load - Loading Stage: tsfile /data/a.tsfile committed 2/4 regions, progress: 50.00%.

Per-file / split details are available at DEBUG:

DEBUG ... Load - Analysis Stage: tsfile [1/3] /data/a.tsfile analyzed in 401 ms, progress: 33.33%.
DEBUG ... Load - Split Stage: splitting tsfile /data/a.tsfile (104857600 bytes).
DEBUG ... Load - Split Stage: tsfile /data/a.tsfile parsed 10485760/104857600 bytes, progress: 10.00%.
DEBUG ... Load - Split Stage: tsfile /data/a.tsfile dispatched 10485760/104857600 bytes in 7 pieces, progress: 10.00%.
DEBUG ... Load - Loading Stage: tsfile [1/3] /data/a.tsfile loaded in 2770 ms.
DEBUG ... Staged piece 7 of LOAD task <uuid> (1048576 bytes).

When a batch has failures, the final report groups them by reason:

WARN ... Load - Loading Stage: failed tsfiles by reason: Region migration: 1, LoadFileException: 2.

A pipe-generated LOAD keeps the same diagnostics but emits all of them at DEBUG.

Verification

  • mvn spotless:apply -pl iotdb-core/datanode and mvn spotless:check -pl iotdb-core/datanode pass.
  • mvn -o -pl iotdb-core/datanode -am -DskipTests -Dmaven.test.skip=true compile passes for the en tree; the same command with -P with-zh-locale clean compile passes for the zh tree. Every new message key exists in both trees with identical {} placeholder counts.
  • LoadProgressLogTest (6 tests) passes: progress buckets, first/bucket/interval logging, heartbeats, percent formatting, throughput and ETA.

@luoluoyuyu
luoluoyuyu force-pushed the feat/load-progress-logging branch from c76b834 to 80a0b21 Compare December 2, 2026 09:52
public static final String LOG_COMMITTING_LOAD_TSFILE_ARG_LOADING_PREPARED_RESOURCES_INTO_DATAREGION_EA1D6335 =
"正在提交 LOAD TsFile {}:将已准备资源加载到 DataRegion。";
public static final String LOG_STAGED_PIECE_ARG_OF_LOAD_TASK_ARG_ARG_BYTES_8F1C2D7F =
"LOAD 任务 {} 的 piece {} 已写入暂存({} 字节)。";

Copy link
Copy Markdown
Member Author

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/i18n/zh/org/apache/iotdb/db/i18n/StorageEngineMessages.java:707 — zh LOG_STAGED_PIECE template prints piece index as load id

The zh template "LOAD 任务 {} 的 piece {} 已写入暂存({} 字节)。" puts the load task first, but LoadTsFileManager.writePiece (en order) passes node.getPieceIndex() then node.getLoadId(). With the zh locale the line prints the piece index as the task and the load id as the piece.

Fix: Restore the en argument order in zh, e.g. "LOAD 任务的 piece {}(任务 {})已写入暂存({} 字节)。".


registerPendingDeletion(node);
logLoadSuccess(filePath, i + 1, totalFiles);
logLoadSuccess(filePath, i + 1, totalFiles, System.nanoTime() - fileStartNanos);

Copy link
Copy Markdown
Member Author

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/queryengine/plan/scheduler/load/LoadTsFileScheduler.java:395 — Loading-stage progress counts loop position as loaded files

logLoadSuccess(filePath, i + 1, totalFiles, ...) runs only for successful files but passes the loop index as the loaded count. For 3 files where index 0 fails and index 2 succeeds it logs "3/3 tsfiles have been loaded, progress: 100.00%" while only 2 loaded, contradicting logLoadFinished's "2/3 tsfiles loaded ..., 1 failed".

Fix: Maintain a succeeded-file counter in start() and pass it as current so the count, percentage and bucket reflect actual successes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May group the failed files by reasons in the final report.

@luoluoyuyu luoluoyuyu Dec 4, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 59a861a: the loading-stage summary now counts the actual successes, and appends a grouped failure line such as failed tsfiles by reason: Region migration: 1, LoadFileException: 2.

return progressBucket(total, done, DEFAULT_BUCKETS);
}

public static int progressBucket(final long total, final long done, final int buckets) {

Copy link
Copy Markdown
Member Author

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/util/LoadProgressLog.java:55 — New LoadProgressLog bucketing/throttling has no unit tests

LoadProgressLog decides when every stage logs (first item, done >= total, total <= 0, 10 s in-bucket re-log) and is used by the analyzer, the scheduler and TwoPhaseConsensusLoadStrategy's package-private helpers, yet no test exists in the repo (no LoadProgressLogTest).

Fix: Add LoadProgressLogTest for progressBucket (0, partial, done == total, total <= 0), shouldLogProgress (first item, bucket advance, just below/at the interval) and formatPercent(total <= 0).

@jt2594838

Copy link
Copy Markdown
Contributor

May also include the percentage of bytes processed, a byte rate, and even an ETA in the progress log.

@luoluoyuyu

luoluoyuyu commented Dec 4, 2026 •

Copy link
Copy Markdown
Member Author

Done in 59a861a: the stage progress now reports the byte percentage plus the average throughput and ETA, and the stage summary reports the average throughput, e.g. 1/3 tsfiles have been loaded, progress: 33.33% (36.10 MB/s, ETA 6s).

Report the progress of a LOAD at the level that matches the audience:

- INFO: the start, the ten-percent progress and the summary of the
  analysis stage and of the loading stage of the whole file list, plus
  the existing PREPARE/COMMIT logs of the receiving regions.
- DEBUG: the analysis and loading of each TsFile, the parse and
  dispatch progress of each source TsFile, and the staging of each
  piece on the receiving side.

Debug lines are only built when debug is enabled, so a user LOAD no
longer emits one INFO line per file while a pipe-generated LOAD keeps
the same diagnostics at DEBUG. Overall progress is bucketed into ten
equal parts and also reported at least every ten seconds inside one
bucket, so a large file neither floods the log nor hides a stall.
Track the loaded file count and bytes instead of the loop index, report
the byte percentage, throughput and ETA in the stage progress and
summary lines, and group the failed files by reason in the loading-stage
report. Fix the zh argument order of the staged-piece log and add unit
tests for LoadProgressLog.
@luoluoyuyu
luoluoyuyu force-pushed the feat/load-progress-logging branch from 2125411 to 59a861a Compare December 4, 2026 03:05
}

final long nowNanos = System.nanoTime();
if (!LoadProgressLog.shouldLogProgress(

@Caideyipi Caideyipi Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Emit progress while a file is being processed

logLoadSuccess is called only after processSingleNode returns, and that call runs the entire strategy for the file. Consequently, shouldLogProgress cannot produce its 10-second updates during a long-running single-file LOAD; at INFO level, users see the start message and then no progress until the file finishes. The new split/dispatch updates are DEBUG-only. Could the in-flight parsing/dispatch path report throttled stage progress, or otherwise provide a heartbeat for the active file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 01bca63: the split, dispatch and commit of the active file now emit throttled INFO heartbeats (at most once per LoadProgressLog.DEFAULT_LOG_INTERVAL_NANOS, sharing one clock), so a single large file keeps reporting between the stage start and finish lines. A pipe-generated LOAD keeps the debug detail only. TsFileSplitter exposes a SplitProgressReporter so the strategy decides the level.

final int analyzedTsFileNum,
final int totalTsFileNum,
final long costNanos) {
analyzedTsFileBytes += tsFile.length();

Copy link
Copy Markdown
Member Author

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/queryengine/plan/analyze/load/LoadTsFileAnalyzer.java:430 — Analysis byte progress reads the file length after the analyzer may have deleted the file

logAnalyzeProgress adds tsFile.length() (line 430) after analyzeSingleTsFile returns, but that method deletes the source file on the empty-TsFile path when ON_SUCCESS DELETE is set (lines 610-619). File.length() is then 0, so analyzedTsFileBytes never reaches totalTsFileBytes: the stage never emits its 100% line and the finished MB/s is understated; a batch of only such files reports 0.00%.

Fix: Capture each file's size before analysis (in doAnalyzeFileByFile before analyzeSingleTsFile) and pass it to logAnalyzeProgress, so a file deleted during analysis still contributes its bytes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 01bca63: doAnalyzeFileByFile now captures tsFile.length() before analyzeSingleTsFile and passes it to logAnalyzeProgress, so a file deleted on the ON_SUCCESS DELETE path still contributes its bytes to the stage progress and throughput.

Report throttled INFO heartbeats for the split, dispatch and commit of
the file being loaded, so a single large file no longer stays silent
between the stage start and finish lines. Capture the TsFile size before
analysis, because the analyzer may delete an empty file on ON_SUCCESS
DELETE, and cover shouldLogHeartbeat with unit tests.
}

++loadedFiles;
loadedTsFileBytes += node.getTsFileResource().getTsFile().length();

Copy link
Copy Markdown
Member Author

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/queryengine/plan/scheduler/load/LoadTsFileScheduler.java:404 — Loading-stage byte progress reads TsFile length after the source file may be deleted

loadedTsFileBytes += node.getTsFileResource().getTsFile().length() runs after processSingleNode returns, but a local load with delete-after-load (LOAD ... WITH DELETE, and every pipe/active load sets deleteAfterLoad=true) deletes the source TsFile inside DataRegion.loadTsFileToUnSequence (DataRegion.java:5081-5094). File.length() is then 0 while totalTsFileBytes (captured in logLoadStart) is not, so every progress line prints progress: 0.00% (0.00 MB/s, ETA 0s), the bucket never advances, and logLoadFinished reports 0.00 MB/s for a successful batch.

Fix: Capture each node's size before processSingleNode and add the captured size on success, as LoadTsFileAnalyzer now does for the analysis stage, instead of re-reading length() after the load.

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