Repository navigation
Improve LOAD progress logging - #19502
luoluoyuyu wants to merge 3 commits into
Conversation
c76b834 to
80a0b21
Compare
| 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 {} 已写入暂存({} 字节)。"; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
May group the failed files by reasons in the final report.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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).
|
May also include the percentage of bytes processed, a byte rate, and even an ETA in the progress log. |
|
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. |
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.
2125411 to
59a861a
Compare
| } | ||
|
|
||
| final long nowNanos = System.nanoTime(); | ||
| if (!LoadProgressLog.shouldLogProgress( |
There was a problem hiding this comment.
[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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
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.
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.Example
Before, a 3-file LOAD emitted one INFO line per file (and one model line per file), with no overall progress:
After, the core progress is aggregated at INFO and reports the byte percentage, throughput and ETA:
For a single large file, the active file also reports throttled INFO heartbeats while it is split, dispatched and committed:
Per-file / split details are available at DEBUG:
When a batch has failures, the final report groups them by reason:
A pipe-generated LOAD keeps the same diagnostics but emits all of them at DEBUG.
Verification
mvn spotless:apply -pl iotdb-core/datanodeandmvn spotless:check -pl iotdb-core/datanodepass.mvn -o -pl iotdb-core/datanode -am -DskipTests -Dmaven.test.skip=true compilepasses for theentree; the same command with-P with-zh-locale clean compilepasses for thezhtree. 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.