Skip to content

fix(iceberg): reclaim unused append file metadata budget - #33646

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/6a6aa315cae4ee21085b9ce93c127ef3e8a0fc65d0091001d55c649c49458789
Dec 2, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/6a6aa315cae4ee21085b9ce93c127ef3e8a0fc65d0091001d55c649c49458789

Conversation

@iamlinjunhong

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:

What this PR does / why we need it:

#32523 preserved actionable Iceberg budget errors and constrained active writer peaks by rotating files under pressure. Closed Parquet files still retained their worst-case column statistics reservation until commit. Those reservations accumulated and caused a single 22 million-row append into an 18-column table to exceed the default 256 MiB budget.

Once a nonempty append file has uploaded successfully, charge its frozen metadata and release the unused reservation. Keep the active writer, upload buffers, and manifest construction subject to the shared hard budget. The adjustment examines column and partition metadata once per file and reduces the charge retained across file rotations.

Validation on this PR

  • On a native Darwin/arm64 MatrixOne deployment with one CN, MinIO, and Nessie, a single append from a native table committed 22 million rows under the default 256 MiB budget in 206.77 seconds. It added one snapshot and 247 uncompressed Parquet files with 11 million rows per DATE partition. SQL readback verified the values and per-ID counts. The wide and two-column scale controls passed, as did the two-column 1 million and 2 million-row controls at 2 GiB.
  • At 4 MiB, an append that exceeded the hard limit returned error 20400 with the budget category, used/requested/limit bytes, and setting names. The snapshot and existing rows stayed intact. A subsequent small append committed and was readable after restart.
  • A two-file regression at 224 KiB committed on this change and hit the budget limit on the second file at the baseline. A cancellation test verified that the sweeper removed both unreferenced uploads after the TTL and kept the committed file readable. The focused cancellation race check passed 100 runs. Changed-package static checks passed, and both Iceberg packages passed race checks on the implementation commit before the test-only follow-up.

Historical QA and pending CI

The previous Linux QA run with an 8 GiB memory+swap cap reproduced the original 22 million-row failure twice. This PR's scale results cover the local single-CN deployment. Repository CI results are pending.

@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 →

@mergify

mergify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 5db33ca4e5cfa84d7bb8e9ff0d236407c7dd5966

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 5db33ca4e5cfa84d7bb8e9ff0d236407c7dd5966

Assessment: request_changes

The change reduces retained append metadata and the focused budget and cancellation checks pass. A file-cardinality limit remains under the default budget, leaving the linked issue's size-independent append requirement unresolved. This is a pre-existing limitation that the PR improves, not a regression introduced by it.

Model: gpt-6.1-terra / max

Session: 01a2350e-851d-7031-94fc-615272373c71 · slot 2 · generation 20

  • P2 pkg/sql/iceberg/dml_replacement_writer.go:130: Append 1,800 rows to an 18-column Iceberg table partitioned by a distinct identity value for each row, using the default 256 MiB budget and default fanout settings.
    Impact: The append fails before commit because retained file-metadata reservations exhaust the budget, even though each partition contains only one row. Issue #32514 asks for default-budget appends of any size, so the reported 22-million-row, two-partition success does not close this distinct file-cardinality case.
    Evidence: Each completed file retains at least 150,528 bytes before dynamic metadata. A coordinator-boundary probe with a fake object writer failed after 1,723 files at the default budget; a 10-partition control passed, and the same 1,800-row writer completed with a 512 MiB budget. See many-partitions-final.log and checks/1796199146859101906-3.json. The base retained a larger per-file reservation, so this remains an existing issue requirement. Handle file metadata and recovery information within the hard budget, or obtain a product-owner decision defining the supported file-count scope.

Validation:

  • Private /tmp and loopback preflight passed: preflight.log and checks/1796192887946208011-3.json.

  • Focused metadata settlement, rejection, rotation, and cancellation tests passed: focused-budget.log and checks/1796196591212359586-3.json.

  • The cancellation and orphan-recovery subtest passed 100 race-enabled repetitions: race-cancel.log and checks/1796196711132427828-3.json.

  • Both affected Iceberg packages passed their full race-enabled test runs: race-packages.log and checks/1796198080104814092-3.json.

  • The targeted capacity probe failed at the default budget while both controls passed: many-partitions-final.log and checks/1796199146859101906-3.json.

  • Native provenance and git diff --check passed: native-provenance-local.log with checks/1796196329279051618-4.json, and diff-check.log with checks/1796198189393823676-3.json.

  • The review plan and discussion assessment exist in the diagnostic directory; all three discussion_index keys are covered exactly once.

Limitations:

  • The capacity probe exercises the runtime coordinator with a fake object writer; it is not an end-to-end SQL or object-store run.

  • The author's reported 22-million-row Darwin/MinIO/Nessie run was not independently repeated, and the supplied local_validation list has no matching retained run.

  • The default Go proxy failed during toolchain bootstrap; the alternate proxy succeeded and subsequent tests used Go 1.27.1.

  • All relative log and receipt paths are under /mnt/nvme/mo-bot-55-live/state/jobs/20e0af71b46947f3180b6d6e/attempt-1.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

The 1,800-partition coordinator probe identifies a real file-count limit. The exact base and head use the same 256 MiB limit and retain a descriptor for every successfully uploaded file until commit or abort. The base charges 740,352 bytes per file for this 18-column, one-partition-field schema. That charge alone would exhaust the budget by the 363rd file. The reviewed head settles each published file to a 150,528-byte structural charge plus dynamic metadata, which is consistent with the later failure observed in the probe. Base reservation · Head settlement

The “any size” sentence in #32514 specifies the default-budget problem in terms of data volume and file rotation for one or two partitions. Its QA follow-up defines the remaining acceptance case as a single 22-million-row, 18-column, two-partition append, with failed-write atomicity and orphan recovery. The review probe adds a different requirement: support a growing number of one-row partition files within the same hard budget. Under the PR scope rule for existing limitations and additional functionality, that requirement belongs in separate work on bounded commit metadata and recovery state. The high-file-count limit remains unresolved. Original issue · QA acceptance · Review

@XuPeng-SH

XuPeng-SH commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 5db33ca4e5cfa84d7bb8e9ff0d236407c7dd5966

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 5db33ca4e5cfa84d7bb8e9ff0d236407c7dd5966

Assessment: approve

The new discussion changes the prior assessment. The 1,800-file default-budget limit is real and remains unresolved, but it predates this change. The author has scoped this PR to reducing retained metadata for the reported large append; the linked QA case specifies a 22-million-row, two-partition workload. No independent contract was identified that makes bounded metadata for the separate high-file-count case a merge requirement for this scoped fix. The existing budget and recovery owners are reused.

Model: gpt-6.1-terra / max

Session: 01a23504-137d-7f93-9b91-fd29f7f60fa2 · slot 1 · generation 42

Validation:

  • Reused exact-head focused settlement, rejection, rotation, and cancellation checks: prior job 20e0af71b46947f3180b6d6e, checks/1796196591212359586-3.json and focused-budget.log.

  • Reused 100 race-enabled cancellation repetitions and full race runs for both affected Iceberg packages: checks/1796196711132427828-3.json and checks/1796198080104814092-3.json, with matching logs in the prior job.

  • Reconciled the prior high-file-count probe and its passing controls with checks/1796199146859101906-3.json and many-partitions-final.log. The latest target advance contains no changes under either affected Iceberg package.

  • The author reports a successful 22-million-row single-CN append with MinIO and Nessie, plus low-budget failure and recovery checks.

Limitations:

  • The original issue’s “any size” wording is broader than the demonstrated workload. This assessment does not establish unlimited file-count support or decide whether the issue should be closed.

  • The author’s 22-million-row deployment run was not independently repeated, and its raw execution artifacts were not supplied.

@mergify mergify Bot added the queued label Dec 2, 2026
@mergify

mergify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request manually updated

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 2 Dec, 09:33 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • 🚫 Left the queue 09:33 · d2f6599

Reason

The pull request #33646 has been manually updated

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit f7deda7 into matrixorigin:main Dec 2, 2026
6 checks passed

This branch was successfully deployed

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

Labels

dequeued 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