Skip to content

fix(external): avoid parquet load timeout from blob capacity - #29425

Merged
XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-29229-parquet-load-stats
Sep 28, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-29229-parquet-load-stats

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29229

What this PR does / why we need it:

  • Do not treat BLOB family capacity widths as observed Parquet payload sizes when estimating LOAD DATA statistics. This preserves distributed AP/multi-CN scheduling while keeping catalog widths for assignment validation.
  • Use binary search for Parquet source-budget page boundaries, including dictionary-backed pages, to avoid repeated prefix scans and temporary page allocations.
  • Add planner execution-class and dictionary-page boundary regressions.

Validation:

  • go test ./pkg/sql/plan ./pkg/sql/colexec/external -run 'Test.*(Parquet|LoadExternalStats|ApplyLoadAssignmentCasts)' -count=1
  • COS/TKE load-only run 36366084312 using commit 9494371491: the one-year Parquet LOAD DATA completed successfully in about 28 minutes, with 1 passed table and 0 failed tables.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@daviszhen

Copy link
Copy Markdown
Contributor Author

Validation result for #29229

The combined fix was validated with the same COS LOAD DATA workflow:

  • Workflow: 36366084312
  • MatrixOne commit: 9494371491de874d89b15eea3e016d26afe46c60
  • Table: parquet_type_conversion_1y.all_type_parquet_1y
  • File: mo-big-data/parquet_type_conversion_100M_merged.parquet
  • Result: Passed tables: 1; failed tables: 0
  • LOAD DATA execution time: 1,688,629.16 ms (about 28m09s)

Comparison with the reproduced runs:

Commit/experiment Result
e5d7afd932 baseline 2,737,854.33 ms (45m38s)
f42330b618 regression cancelled after more than 100 minutes
cast-only experiment cancelled after more than 100 minutes
binary-search budget only 5,115,168.07 ms (85m15s)
9494371491 combined fix 1,688,629.16 ms (28m09s)

The result is about 38% faster than the recorded baseline and about 67% faster than the budget-only experiment. The runs use the same table, COS object and load-only workflow; TKE resource/network variance means this is validation rather than a controlled per-change benchmark.

The code evidence points to two contributing causes:

  1. f42330b618 made BLOB family widths represent assignment limits, but the Parquet fallback row-size estimator counted those capacities as observed payload sizes. The resulting estimate changed the plan from AP/multi-CN to TP. The fix excludes BLOB capacity from the Parquet estimate while preserving the catalog width for assignment validation.
  2. Dictionary-backed Parquet pages used repeated one-row Page.Slice prefix scans when finding the source-byte budget boundary. The binary-search path removes that repeated scan/allocation overhead and is covered by boundary tests.

Focused package tests also pass:

go test ./pkg/sql/plan ./pkg/sql/colexec/external \\
  -run 'Test.*(Parquet|LoadExternalStats|ApplyLoadAssignmentCasts)' -count=1

@XuPeng-SH XuPeng-SH left a comment

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.

Deep review of all six changed files at 20cd55ebe8ba230ed821affd4db5b8f4d40d1fdc, against merge-base 932213301784bd2e3196ea66bad928aa7d4a3a3a. APPROVE: no blocking correctness, unhappy-path or engineering issue found. No subagents were used.

The direction is appropriate for this focused bug fix. Assignment capacity must not become an observed Parquet payload size. The local estimator copy preserves the catalog type and assignment checks while restoring the previous BLOB estimate. Reusing the existing prefix search for dictionary pages removes a separate row-at-a-time path. The two production files together change +24/-22 lines; no cache, worker, framework or additional long-lived state is introduced. A separate feature-design artifact is not required for this bounded repair.

Closure Review and QA outcome
LOAD planning Traced source-parameter normalization, row-size fallback, estimated rows/blocks, execution-class selection and byte-based parallel sizing. All four BLOB capacity widths keep the original catalog value; text/CSV sampling and assignment enforcement remain separate. The original 31-column case reaches the expected execution class. The fallback remains an estimate, not footer cardinality.
Dictionary source budget For valid decoded pages, summed prefix payload/level sizes are monotone; the lower-bound search preserves the first crossing row, empty/null behavior and progress. Checked both scalar and mixed nested/scalar consumers through mapping, rollback of overshoot, page advancement and reader cleanup.
Adjacent counterexample Added a review-only independent oracle using two actual dictionary pages: required strings including empty values plus optional fixed-width integers, different offsets in each page, every available prefix and budgets 0..95. Expected sizes are computed from input values, not Page.Slice or parquetDecodedPageSize. It passes.
Unrelated account test edit Inspected the complete surrounding synchronization. CREATE completion errors, concurrent gate-holder observations, writer order and cleanup assertions remain. Polling observes cross-CN catalog visibility from a separate SQL connection; it does not rerun CREATE or turn an unsuccessful CREATE into success. Keep this narrow scope explicit when describing the CI fix.

Q1: estimator copies are call-local/GC-owned; page views do not acquire a new external cleanup owner. Existing reader/page/vector cleanup paths remain in place. Q2: the search has a finite decreasing integer interval and adds no blocking edge; error/cancel handling remains with the reader and mapper. Q3: retained batch limits and the single-oversize-row contract are unchanged; the new estimator work is proportional to column count, with no retained state.

Fresh local validation, using matching provenance-verified CGo dependencies, Go 1.26.4 and -short -tags matrixone_test -count=1: Parquet/LoadExternalStats/ApplyLoadAssignmentCasts selections pass in plan (2.614s) and external (2.359s); the independent mixed-column oracle passes (0.01s test body). The owning-package/static/public-path evidence is reused from successful current-head CI, including UT, coverage, SCA and both BVT variants.

Performance interpretation: binary search reduces the number of page-slice operations, but each dictionary prefix size still scans indices, so total work is not simply O(log rows). The reported COS run at 9494371 succeeded; its 28-minute result and percentage comparisons remain historical workload evidence, not a universal speedup or a fresh measurement of this rebased head. The intervening base also changed mixed nested/scalar reading, which was included in the current source tracing and focused tests.

There are no prior human reviews or inline threads to close on this PR. Non-blocking cleanup: consolidate the root-level issue-29229-analysis.md into final problem/decision/evidence documentation; it currently retains experiment history. Long-term footer-derived statistics can be handled separately without expanding this fix.

Review-only QA sources/logs are retained under /private/tmp/mo-review-29291-29425.q67o1N/. No PR source or test changes were submitted.

@mergify mergify Bot added the queued label Sep 28, 2026
@mergify

mergify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-28 09:23 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-28 09:27 UTC · at 50dad4be1ec9ac9073105b2e1e0286631f6ad045

This pull request spent 3 minutes 58 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants