Skip to content

dumpformat: track Parquet scan progress by source file offset - #70307

Merged
ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
D3Hunter:codex/track-parquet-scan-progress
Aug 4, 2026
Merged

ti-chi-bot[bot] merged 4 commits into
pingcap:masterfrom
D3Hunter:codex/track-parquet-scan-progress

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #70306

Problem Summary:

The Parquet parser estimated scanned bytes from decoded datum sizes. Those sizes are independent of the original file's encoding, compression, metadata, and column layout, so byte progress and derived import metrics did not reflect the original file size. A 1,307-byte regression file, for example, reported only 400 bytes after every row had been read.

What changed and how does it work?

  • Track the high-water source-file offset reached across concurrent Parquet column readers.
  • Advance progress for whole-file and row-group preloads while excluding metadata-only footer reads.
  • Account for bytes consumed by partial streaming reads and clamp reported progress to the source file size.
  • Report the exact original file size once all rows are read.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

3 parquet files, total size 5,040,619 bytes
before the tidb_import_bytes{state="restored"} metric is 48,000,024 bytes, after this pr, it's 5,040,619

  • No need to test
    • I checked and no code files have been changed.

The regression assertion failed at the base commit with expected: 1307, actual: 400 in both row-group and whole-file preload modes, and passes with this change.

Validation commands:

./tools/check/failpoint-go-test.sh pkg/dumpformat/parquetfile -run '^(TestParquetParser|TestParquetParserMultipleRowGroup)$' -count=1
make lint

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix an issue where Parquet import progress metrics were calculated from decoded row sizes instead of the original source file size.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Parquet import progress tracking with smoother, monotonic scanned-position updates.
    • Progress estimates now remain accurate for empty, partially processed, completed, and very large files.
  • Reliability

    • Improved handling of Parquet files with multiple row groups and columns across preload and streaming modes.
  • Documentation

    • Clarified how scanned-position progress is reported during imports.
  • Tests

    • Expanded coverage for column reading and progress reporting across varied file sizes and processing states.

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a241d5ba-9c58-4d64-b5fe-05d02736de9c

📥 Commits

Reviewing files that changed from the base of the PR and between 4f6ad86 and 0dc7df6.

📒 Files selected for processing (2)
  • pkg/dumpformat/parquetfile/parser.go
  • pkg/dumpformat/parquetfile/parser_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/dumpformat/parquetfile/parser.go
  • pkg/dumpformat/parquetfile/parser_test.go

📝 Walkthrough

Walkthrough

The Parquet parser now estimates ScannedPos from consumed rows instead of decoded datum sizes. The change handles empty, partial, complete, invalid, and large files. Tests cover preload and streaming modes, and the API documentation defines monotonic estimated progress.

Changes

Parquet scan progress

Layer / File(s) Summary
Row-based scanned position
pkg/dumpformat/parquetfile/parser.go, pkg/lightning/mydump/parser.go
The parser removes estimated byte accumulation and computes ScannedPos from consumed-row proportions. The interface documentation allows estimated monotonic source-byte progress.
Progress behavior validation
pkg/dumpformat/parquetfile/parser_test.go, pkg/dumpformat/parquetfile/BUILD.bazel
Tests cover multiple columns, preload modes, streaming reads, proportional offsets, bounded monotonic progress, and final file-size coverage. The test target uses 28 shards.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • pingcap/tidb#70193: Both changes modify Parquet parser row-reading, preload behavior, and ScannedPos tracking.

Suggested reviewers: gmhdbjd

Poem

A rabbit counts rows across the file,
Progress moves forward mile by mile.
Empty and complete states hold their place,
Partial reads match the source-file space.
The scan now finishes at the file-size gate.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change to Parquet scan progress tracking by source-file offset.
Linked Issues check ✅ Passed The changes make Parquet progress monotonic, bounded by file size, and complete at the encoded source-file size required by issue #70306.
Out of Scope Changes check ✅ Passed The parser change, regression tests, documentation, and test sharding support the linked issue and contain no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 14 UNAVAILABLE: read ECONNRESET


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.8300%. Comparing base (f8848b3) to head (0dc7df6).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #70307        +/-   ##
================================================
- Coverage   76.3227%   73.8300%   -2.4928%     
================================================
  Files          2041       2088        +47     
  Lines        559123     588915     +29792     
================================================
+ Hits         426738     434796      +8058     
- Misses       131485     152873     +21388     
- Partials        900       1246       +346     
Flag Coverage Δ
integration 42.2596% <0.0000%> (+2.5933%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 59.8807% <ø> (ø)
parser ∅ <ø> (∅)
br 46.0614% <ø> (-16.6311%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ingress-bot

Copy link
Copy Markdown

🔍 Starting code review for this PR...

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 3
  • Inline comments: 1
  • Summary-only findings (no inline anchor): 2
Findings (highest risk first)

🟡 [Minor] (3)

  1. ScannedPos comment contradicts the shared Parser interface contract (pkg/dumpformat/parquetfile/parser.go:555, pkg/lightning/mydump/parser.go:144)
  2. scanProgress doc comment describes only the column-reader path, but preload paths update it too (pkg/dumpformat/parquetfile/parser.go:314, pkg/dumpformat/parquetfile/reader_wrapper.go:175)
  3. ScannedPos scale redefinition breaks parquet restore-progress metrics across an upgrade/downgrade resume boundary (pkg/dumpformat/parquetfile/parser.go:555, lightning/pkg/importer/chunk_process.go:724, lightning/pkg/importer/chunk_process.go:617, lightning/pkg/importer/chunk_process.go:124)

Unanchored findings

🟡 [Minor] (2)

  1. ScannedPos comment contradicts the shared Parser interface contract
    • Request: Update the shared mydump.Parser.ScannedPos interface doc to note that per-format implementations (like parquet, with disjoint/parallel column readers) may return an approximation rather than a literal reader pointer, mirroring how Pos already documents per-format differences just above it.
  2. scanProgress doc comment describes only the column-reader path, but preload paths update it too
    • Request: Reword the comment to describe scanProgress as tracking the furthest byte offset reached by any reader that loads row-group data — streaming per-column readers or bulk preload — not just "column readers".

Comment thread pkg/dumpformat/parquetfile/parser.go Outdated
// track the footer.
return fileSize, nil
}
return min(max(pp.progress.current(), int64(0)), fileSize), nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 [Minor] ScannedPos scale redefinition breaks parquet restore-progress metrics across an upgrade/downgrade resume boundary

Impact
The persisted parquet checkpoint field RealOffset is taken from ScannedPos, which this PR redefines from an estimated decoded-datum byte count to an on-disk file offset. A parquet chunk checkpointed by one binary and resumed by another (rolling upgrade or downgrade) mixes the two incompatible scales for the same chunk, so the StateRestored progress math diverges from a same-version run.
Data correctness is unaffected because resume seeking uses the row-based Chunk.Offset via SetPos, not RealOffset.

Scope

  • pkg/dumpformat/parquetfile/parser.go:555 — Parser.ScannedPos
  • lightning/pkg/importer/chunk_process.go:724 — deliverLoop
  • lightning/pkg/importer/chunk_process.go:617
  • lightning/pkg/importer/chunk_process.go:124

Evidence
New ScannedPos returns min(max(pp.progress.current(),0), fileSize) (a file offset), while the old path returned totalReadBytes (a decoded-datum estimate, typically larger than the on-disk size). That value is persisted as cr.chunk.Chunk.RealOffset and reused as startRealOffset on resume; the parquet branch only adds to BytesCounter when currRealOffset > startRealOffset, so an old large datum-estimate startRealOffset makes the new small file-offset base fail the guard and the restored-bytes metric stalls for that chunk. Resume positioning is unaffected: SetPos(chunk.Chunk.Offset, ...) at line 124 seeks by row count.

Change request
Since RealOffset is progress-metrics-only for parquet and resume is row-based, either rebase the parquet restore-progress from the post-SetPos ScannedPos on resume (rather than trusting the persisted RealOffset scale), or gate/version the field and note in release docs that parquet restore-progress metrics may be inaccurate for chunks resumed across this upgrade/downgrade boundary. Add a regression test that resumes a parquet chunk whose persisted RealOffset uses the old datum-estimate scale and asserts progress does not stall.

Comment thread pkg/dumpformat/parquetfile/parser.go Outdated
Comment on lines +553 to +554
// Parquet may read disjoint column ranges, so this returns the furthest data
// offset reached by any reader rather than a single underlying reader position.

@joechenrh joechenrh Aug 4, 2026 •

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.

The "furthest data offset" must be produced by the last column in the current row group, so the watermark can only be advanced by the last column reader. How about using this as an rough estimation

ScannedPos = fileSize × totalReadRows / totalRows

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 4, 2026
@D3Hunter

D3Hunter commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/hold

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 4, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, joechenrh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 4, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-04 06:27:18.019067844 +0000 UTC m=+2509424.055162900: ☑️ agreed by GMHDBJD.
  • 2026-08-04 08:02:13.801294844 +0000 UTC m=+2515119.837389890: ☑️ agreed by joechenrh.

@D3Hunter

D3Hunter commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 4, 2026
@D3Hunter

D3Hunter commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/retest
/retest

@D3Hunter

D3Hunter commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/unhold

@D3Hunter

D3Hunter commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot
ti-chi-bot Bot merged commit c48a991 into pingcap:master Aug 4, 2026
35 checks passed
@D3Hunter
D3Hunter deleted the codex/track-parquet-scan-progress branch August 5, 2026 01:50
@D3Hunter

D3Hunter commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-202603

@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-202603: #70345.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-202603

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

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

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet import progress metrics do not reflect the source file size

5 participants