Skip to content

Fix Iceberg append memory pressure handling - #32523

Merged
XuPeng-SH merged 18 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/505663264bd84c9dd52af95f52326007675bfc89923208ead36cc6dca96e4109
Nov 23, 2026
Merged

XuPeng-SH merged 18 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/505663264bd84c9dd52af95f52326007675bfc89923208ead36cc6dca96e4109

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Nov 11, 2026 •

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 #32514

What this PR does / why we need it:

Large Iceberg appends could exhaust the shared write memory budget even when the data could be written across multiple files. Rotate active partition writers under memory pressure while retaining hard budget admission, and preserve actionable memory-limit details across the DML error chain. Failed writes retain the existing cleanup and orphan ownership semantics.

Validation:

  • Reviewed head 8074dfd0fbabe54b20958a3400bcf81fd9f0e7c1 against base d9190ff6d01d15d60acdfcdc9acd96f807a7ab6a. On this head, Iceberg writer and runtime package tests passed, including shared-budget, partition and factory cancellation cases; 32 focused Iceberg planner tests and five composite-index planner tests also passed.
  • On this head, two 4 MiB single-CN runs with MinIO/Nessie verified multi-file readback, a genuine budget rejection with unchanged snapshot and seed data, cleanup, and an indexed-source insert with exact readback. The physical index operator was not confirmed by EXPLAIN. The complete low-budget suite and other deployment topologies were not run in this exercise.
  • Earlier local integration runs covered default and higher-budget writes; focused race and static checks passed where applicable. The factory cancellation test uses a controlled upload barrier; public SQL cancellation/KILL evidence was timing-triggered, and self-KILL, server timeout and physical object deletion were not separately verified.
  • Earlier performance comparisons used the pre-merge binaries, not a measurement of this head: eight-partition median +3.98% and warmed SQL medians +6.59% / +3.16% against the baseline. Samples were noisy and individual long-tail delays remain unexplained; indexed-source performance, remote storage and production concurrency were not measured.
  • CI repair b0641dbf3cb1ed67f90f9e4226f0585ba451abc0: reproduced run 42983922855 attempt 1 failures locally (SCA nilness in fanout close handling; coverage policy forbidding bare error constructors in tests). Simplified the guarded close-error return and used moerr in both affected test fixtures. Five focused tests and all tests in ./pkg/iceberg/api ./pkg/iceberg/write ./pkg/sql/iceberg passed via mo-cgo-test -count=1 -timeout=240s -cover; configured golangci-lint passed for api/dml/metadata/write/sql-iceberg (0 issues). These are new local Go 1.27.1 Darwin/arm64 checks; earlier integration evidence is reused because this repair preserves behavior.
  • Follow-up repair c549a60cdb18d5c5ba54e2007e0401f8d749717a: maintain the saturated sum of active writer sizes incrementally, removing the per-row full map scan while preserving pressure thresholds, LRU selection, cleanup and hard admission. Added accounting/error-boundary and E2E oracle tests, including negative controls and seed-failure cleanup/report finalization. All six related packages passed via mo-cgo-test -count=1 -timeout=240s -short -tags matrixone_test -coverprofile=... (api/dml/metadata/write/sql-iceberg/test-iceberg); final edited owners were retested. Configured lint passed for the six packages (0 issues).
  • The exact run 42992611890 artifact/profile and its parser (matrixorigin/CI revision 79c604b5c2c265427185271ab68629c9a464cbd0) reproduced the failed changed-block gate: 129/230 (56.09%). Applying that parser to new local package coverage gives 181/233 (77.68%, required >75%). This is local Darwin/arm64 Go 1.27.1 evidence, not a new Linux CI verdict.
  • Three samples per size of an isolated no-pressure check benchmark (1/8/2000 open empty writers) show the 2000-writer case moving from 13.3–13.4 microseconds to 2.67–2.70 nanoseconds, with zero allocations; full SQL throughput was not remeasured. Earlier public integration evidence is reused because pressure decisions and admission semantics are retained.
  • On head b0641dbf3cb1ed67f90f9e4226f0585ba451abc0, SCA, UT coverage tests and both Compose BVT jobs passed; the coverage merge gate failed as described above. Full repository Linux CI and the standard Docker integration path were not run locally. New CI remains pending delivery; Iceberg E2E Local was skipped.
  • Conflict repair 52e6709632323e57c25b22f7de2c29af15d57db1: rebased onto official main 74ad90d47c83426604ab895a3faa09b7de3e6cbe. Preserved upstream Parquet compression/options and flush/failure tests alongside pressure/accounting tests; append creation retains both initial hard budget admission and Parquet option validation. No protocol capability or scope expansion.
  • New local validation on this rebased head (Go 1.27.1 Darwin/arm64 CGo): six related packages passed with mo-cgo-test -count=1 -timeout=240s -short -tags matrixone_test -coverprofile=...; focused -race tests matching TestFanout|TestAppendRuntime|TestBuffered|TestReplacementFanout passed in write/sql-iceberg. Configured six-package lint passed (0 issues), formatting/whitespace and delivery-artifact checks passed. The same CI parser reports 181/233 changed blocks covered (77.68%, required >75%). Raw profiles/logs remain outside source.
  • Prior head c549a60cdb18d5c5ba54e2007e0401f8d749717a completed run 43003052359 attempt 2 successfully, including UT and CI Required. Earlier public SQL/performance evidence remains historical: no fresh external-service E2E, full low-budget suite, topology or SQL-throughput measurement is claimed after the upstream codec change. New CI will run after this rebase is pushed.
  • Queue-update repair 3375c46f815cbe1ac0e9fb36cbec3bf85ca76941: manually rebased onto official main c8accd138bb91144050ff173100afd7a71a02888 after Mergify check 130767038469 reported a workflows permission denial while updating the branch with main's Python SDK workflow change. All 16 PR patches are unchanged by range-diff; six owning package trees and module/native/lint inputs are byte-identical to head 52e6709632323e57c25b22f7de2c29af15d57db1. A fresh dependency check excludes the newly changed planner package from those owning tests. Reuse the prior six-package/race/lint/77.68% coverage evidence and successful Actions attempt 2; no new runtime test is claimed. Formatting/whitespace and delivery-artifact checks passed. This changes no application permissions, protocol capability or product behavior; new CI remains pending the push.
  • Conflict repair 6fa3f7fb4095830d89db5df9ed3118e1ebde68f2 rebases onto official main 4cadd4f2f6ed9444d8bdbf6e13053b5ac741863c. The append runtime test retains both sides of the import conflict. The affected Iceberg fixtures now pass their existing memory pool to the upstream vector.NewVec API and keep their existing assertions.
  • Local Go 1.27.1 Darwin/arm64 validation passed for the six owning packages with mo-cgo-test -short -tags matrixone_test -count=1 -timeout=240s and coverage. The two changed packages also passed focused fanout, append runtime, buffered and replacement fanout race tests. Configured lint, diff checks and the delivery artifact check passed. The previously pinned CI parser calculated 181/233 (77.68%) changed blocks from the local profiles. External-service SQL E2E and Linux CI were outside this local run.

@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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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

@MatrixAdventurer

Copy link
Copy Markdown
Contributor

pkg/iceberg/write/fanout_writer.go:310(WriteBatch):每行写入前后各调用一次 relieveMemoryPressure,只要 dml-max-memory>0(limited=true),即使预算远未吃紧,两个调用点每行也都各自执行一次 AvailableMemory,并遍历全部活跃写入器求和后才做阈值判断。宽分区批量导入下是 O(行数×活跃分区) 的额外开销(如 1e7 行×2000 分区 ≈ 4×10^10 次 map 访问),与是否存在内存压力无关,纯 CPU 代价可观。建议为 active 写入器维护增量 size 计数(写入/轮转时增减),或按块粒度(每次 flush 或每 N 行)检查一次预算,仅在可能越过阈值时才做 LRU 求和与轮转。

本操作由LW授权的MOI智能体提交

@mergify

mergify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🛑 Queue command cancelled

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

@mergify

mergify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

58 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Mon 23 Nov, 03:23 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 04:20 · ffe916a

Reason

Pull request #32523 has been dequeued

Pull request from fork cannot be queued. This pull request comes 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.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

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

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

This branch had an error being deployed

1 failed deployment
ci — ffe916a8 Deployed Nov 23, 2026 by mergify[bot]
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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants