Skip to content

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

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-70307-to-release-nextgen-202603
Aug 5, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-70307-to-release-nextgen-202603

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #70307

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 scan progress reporting for Parquet files, including empty, partially read, and fully consumed files.
    • Scan positions now advance consistently across row-group preloading and streaming scenarios.
  • Documentation

    • Clarified that scan positions represent estimated monotonic source-byte progress when direct reader positions are unavailable.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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. type/cherry-pick-for-release-nextgen-202603 labels Aug 5, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@D3Hunter This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

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.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Parquet scan progress no longer sums decoded row sizes. It estimates source-file progress from consumed rows, reports the file size for empty or fully consumed files, and adds coverage for preload, streaming, partial-read, and large-file cases.

Changes

Parquet scan progress

Layer / File(s) Summary
Scan-position contract and implementation
pkg/lightning/mydump/parser.go, pkg/lightning/mydump/parquet_parser.go
The ScannedPos contract now permits estimated source-byte progress. ParquetParser uses totalReadRows / totalRows instead of decoded-byte accumulation and returns the source file size for empty or fully consumed files.
Scan-position validation
pkg/lightning/mydump/parquet_parser_test.go
Tests cover multiple row groups, preload modes, per-column streaming, partial reads, complete reads, empty files, and bounded monotonic positions.

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

Possibly related PRs

  • pingcap/tidb#70307: Updates the same Parquet scan-position calculation, tests, and documentation.

Suggested labels: approved, lgtm

Suggested reviewers: gmhdbjd, joechenrh

Poem

I’m a rabbit counting rows in a stack,
Source bytes now guide the progress track.
Empty or complete, the file size is clear,
Streaming and preload behave sincere.
Hop, hop—the scan reaches the rear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Parquet scan-progress change and its use of source-file offsets.
Description check ✅ Passed The description includes the issue number, problem, implementation details, tests, side effects, documentation status, and release note.
Linked Issues check ✅ Passed The changes satisfy #70306 by tracking source offsets, preserving monotonic bounded progress, and reporting the full file size after all rows are read.
Out of Scope Changes check ✅ Passed The code and tests remain focused on Parquet scan-progress tracking and related documentation, with no unrelated changes identified.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/lightning/mydump/parquet_parser.go`:
- Around line 529-538: The scan progress logic should handle row-count overshoot
without returning a position beyond the file. In the progress calculation near
totalRows and totalReadRows, change the completion check to totalReadRows >=
totalRows, and clamp the computed progress position to fileSize before returning
it. Add a test covering totalReadRows greater than totalRows.
- Around line 520-539: Resolve the cherry-pick conflicts and remove all conflict
markers. In pkg/lightning/mydump/parquet_parser.go lines 520-539, implement
ScannedPos on *ParquetParser and retain the source-progress logic using its
metadata and row counters, not the Parser interface. In
pkg/lightning/mydump/parquet_parser_test.go lines 248-258, pass the
package-local metadata required by newParquetParserForTest; at lines 290-292,
construct &ParquetParser with fileMeta instead of &Parser.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0880a3af-a3e2-44f0-b69b-a229df399830

📥 Commits

Reviewing files that changed from the base of the PR and between e97fbba and 39094c7.

📒 Files selected for processing (4)
  • pkg/dumpformat/parquetfile/BUILD.bazel
  • pkg/lightning/mydump/parquet_parser.go
  • pkg/lightning/mydump/parquet_parser_test.go
  • pkg/lightning/mydump/parser.go

Comment thread pkg/lightning/mydump/parquet_parser.go Outdated
Comment on lines +529 to +538
if pp.totalRows <= 0 {
return fileSize, nil
}

if pp.totalReadRows == pp.totalRows {
return fileSize, nil
}

progress := float64(pp.totalReadRows) / float64(pp.totalRows)
return int64(progress * float64(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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clamp scan progress when row counters reach or exceed the total.

totalReadRows == totalRows only handles exact completion. If totalReadRows exceeds totalRows, the ratio can return a position larger than fileSize.

Return fileSize when totalReadRows >= totalRows. Clamp the calculated value to fileSize. Add an overshoot test case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/lightning/mydump/parquet_parser.go` around lines 529 - 538, The scan
progress logic should handle row-count overshoot without returning a position
beyond the file. In the progress calculation near totalRows and totalReadRows,
change the completion check to totalReadRows >= totalRows, and clamp the
computed progress position to fileSize before returning it. Add a test covering
totalReadRows greater than totalRows.

Signed-off-by: D3Hunter <jujj603@gmail.com>
@ti-chi-bot

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

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

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
pkg/lightning/mydump/parquet_parser_test.go (1)

286-325: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add an over-read case for the clamp contract.

The complete case tests totalReadRows == totalRows. It does not test totalReadRows > totalRows. Add an over-read case to prove that ScannedPos() remains equal to the source file size.

Suggested test case
 		{name: "complete", fileSize: 101, readRows: 10, totalRows: 10, expected: 101},
+		{name: "over-read", fileSize: 101, readRows: 11, totalRows: 10, expected: 101},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/lightning/mydump/parquet_parser_test.go` around lines 286 - 325, Extend
the table-driven cases in TestParquetScannedPosByReadRows with an over-read
scenario where totalReadRows exceeds totalRows, and assert that ScannedPos()
returns the source file size. Keep the existing complete and other boundary
cases unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/lightning/mydump/parquet_parser_test.go`:
- Around line 286-325: Extend the table-driven cases in
TestParquetScannedPosByReadRows with an over-read scenario where totalReadRows
exceeds totalRows, and assert that ScannedPos() returns the source file size.
Keep the existing complete and other boundary cases unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 79d2fcea-7996-40fe-8ea7-e2e0ce9b30a2

📥 Commits

Reviewing files that changed from the base of the PR and between 39094c7 and 232a26a.

📒 Files selected for processing (2)
  • pkg/lightning/mydump/parquet_parser.go
  • pkg/lightning/mydump/parquet_parser_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/lightning/mydump/parquet_parser.go

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

ti-chi-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, 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 5, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-05 07:41:32.142894854 +0000 UTC m=+2600278.178989910: ☑️ agreed by D3Hunter.
  • 2026-08-05 07:45:42.686518806 +0000 UTC m=+2600528.722613862: ☑️ agreed by joechenrh.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-nextgen-202603@e97fbba). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #70345   +/-   ##
===========================================================
  Coverage                          ?   76.2230%           
===========================================================
  Files                             ?       1937           
  Lines                             ?     541462           
  Branches                          ?          0           
===========================================================
  Hits                              ?     412719           
  Misses                            ?     128743           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.2230% <100.0000%> (?)

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

Components Coverage Δ
dumpling 61.5065% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 48.7938% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot
ti-chi-bot Bot merged commit 293ab37 into pingcap:release-nextgen-202603 Aug 5, 2026
18 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-70307-to-release-nextgen-202603 branch August 5, 2026 08:02
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. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants