Repository navigation
[4.2-dev] fix(catalog): prevent property amplification across ALTER rewrites - #32496
Conversation
…atrixorigin#32465) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#32463. Related to matrixorigin#31888; this PR does not close the original distributed OOM incident. ## What this PR does / why we need it: Repeated in-place ALTER reads persisted `StreamConfigsDef` properties, appends catalog kind/CreateSQL/comment again, and writes all of them back. Even an empty table with an unchanged logical definition accumulates duplicate properties on every rewrite. This change restores the catalog-column ownership boundary at both existing planner projection sites (`cache.getTableDef` and `txnTable.GetTableDef`). One small catalog helper excludes only `relkind`, `rel_createsql` and `rel_comment` from the persisted configuration import. Each reader continues to project its current authoritative catalog values, including authoritative empty values. Other properties retain their values, order and duplicate semantics. The helper does not modify the input configuration, cached property objects, original serialized constraint, or PK/FK/index definitions. Normal subsequent ALTER compacts historical duplicate properties; no bulk rewrite or on-disk format change is introduced. Deploy using the existing shutdown-upgrade procedure. Tests cover both readers, fixed-size feedback through the actual planner and engine conversion functions, legacy duplicate constraints, custom properties, empty/current metadata and unaffected constraints. A small SQL BVT checks repeated ALTER, bounded serialized metadata, SHOW CREATE/data, primary and unique keys, and foreign-key enforcement. ### Validation on host50 - Base: Main `0c8bd5e5f3be4ce5582201513161181ddca37d6d`; Linux/amd64, Go 1.27.1. Own matching native artifacts were built using `make cgo`. - **Red before green:** the final regression tests fail at runtime with the original reader source overlaid from that exact base; the fixed tests pass. Cases include fresh metadata, historical repeated configuration groups, authoritative empty values, custom duplicate keys and constraint preservation. - All owning packages passed with the repository CGo wrapper: `./pkg/catalog`, `./pkg/vm/engine/disttae/cache`, `./pkg/vm/engine/disttae` (`-p=2 -count=1 -timeout=360s`). - `go vet` and repository-pinned golangci-lint 2.14.0 passed for the changed three-package closure, including newly added files; gofmt/diff checks clean. This is incremental local static validation, not a full CI claim. - Built the actual Main `mo-service` with the patch. Isolated local LOG/TN/CN, fresh data, internal-only network, 4 GiB / two CPU; no shared service touched. Binary SHA256: `8f6bc3205e7f8cc9c049d2add48881d20ec2976d49d84a0fb3a46d82d64df380`. It was built before commit, so VCS metadata is the base plus modified=true; saved source-file hashes bind it to the delivered production contents. - Reviewed the generated expected output independently, then ran the new BVT in **normal comparison mode twice on the same instance**: both **21/21**, zero failed/ignored/abnormal, 0.220s and 0.222s. Database/table teardown counts are zero after each run. - Additional bounded public SQL: 100 identical `MODIFY col2 VARCHAR(25) NOT NULL` operations. Constraint bytes are **298 / 298 / 298** at rounds 1 / 10 / 100; row count remains zero and SHOW CREATE is correct. The initial INT definition is 157 bytes; the first conversion legitimately changes the definition size. - Restarted with a separate one-row persisted fixture: SHOW CREATE and row `(1, '12')` match before/after restart; another ALTER preserves the encoded size. Final test database/table counts are zero. The owned container and network were removed; service exit code 0, OOMKilled=false. Local evidence (commands, raw logs, source/binary hashes and cleanup receipts): `/tmp/mo-catalog-property-fix-20261110.48eDEMbs/evidence.md` on host50. ### Scope limits No changes to Catalog GC retention, GOMEMLIMIT, memory cache, resource admission, background work or regression workflow. Existing raw metadata/history follows normal replacement/GC; this is not an immediate global cache purge. The focused local proof establishes property idempotence and SQL compatibility, not the complete 55 GiB distributed OOM outcome or every Main/4.2 RSS difference. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 5318305)
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 5bddc6e6fc88ae48b1ff71dff142673a31a626c8
Assessment: approve
The backport fixes property feedback at the existing catalog projection boundary. Both readers reuse one narrow filter, preserving custom properties, input ownership and the constraint format. No actionable findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
All three focused regression roots passed across catalog, cache and transaction readers. Restoring the original readers makes the same round-trip and stale-property assertions fail.
-
Reviewed all eight changed files, three discussion entries and linked issue context. Native inputs, source fingerprints, formatting, logs and receipts are reconciled in receipt-reconciliation.json.
-
Reused supplied exact-head CI successes for build, owning UT, SCA, coverage and active BVT.
Limitations:
-
The full distributed OOM incident remains outside this scoped metadata fix.
-
Author-reported host50 SQL/restart results and broad CI checks lack raw local logs; no fresh local full SQL, restart or distributed workload pass is claimed.
What type of PR is this?
Which issue(s) this PR fixes:
4.2-dev backport for #32463. Main fix: #32465.
Related to #31888; this change does not close the entire distributed OOM incident.
What this PR does / why we need it:
Cherry-picks merged Main commit
5318305e0269c254b8ea22be7ddc2c430f3e73f8onto 4.2-dev
a7bc2008e9236708fee0328376f2c2c6b6f0d3fc. Production code andtest SQL/assertions are unchanged. The only branch adaptation is adding the
existing 4.2
internal error:prefix to two foreign-key error messages in theexpected result. It does not import unrelated Main changes.
Repeated ALTER re-imported persisted catalog properties and appended the current
catalog values again. The two existing table-definition readers now exclude
historical
relkind,rel_createsqlandrel_commentcopies before projectingthe authoritative catalog columns. Rewriting an unchanged definition no longer
accumulates these properties.
Custom properties retain their values, order and duplicate semantics. No input
constraint bytes or shared property objects are modified. PK/FK/index definitions
and the existing binary format remain unchanged. Historical duplicate properties
are compacted by subsequent normal schema rewrites, not by a background migration
or global cache purge. No GC, memory-budget, workflow or topology changes.
Branch-specific validation on host50
stale properties; the unchanged tests pass with the backport.
./pkg/catalog,./pkg/vm/engine/disttae/cache,./pkg/vm/engine/disttae.go vet, repository-pinned golangci-lint 2.6.2 and format/diffchecks pass.
mo-service; ran it with fresh data in an isolated localLOG/TN/CN fixture (4 GiB, two CPU, internal-only network).
prefixes described above. After adapting those expected strings, the final
BVT passed twice: 21/21 each, zero failed/ignored/abnormal, 0.148s/0.129s.
This checks metadata size, SHOW CREATE, data and PK/unique/FK enforcement.
rounds 10 and 100, with zero data rows. The initial INT definition and first
conversion legitimately have different sizes; the invariant is no continued
growth after metadata warmup.
(1, '12')match before/afterrestart; another ALTER retains the encoded size. All owned databases/tables
are absent afterward. The isolated container/network were removed;
service exit code 0, OOMKilled=false.
2f40ae6a4031234938f90b63afb45210d8b25047cd9e897fa95861fa6db15d13.Built from cherry-pick
b36095852f; final commit5bddc6e6fcchanges onlythe two expected error strings. Production/test source hashes are unchanged,
and the final golden was exercised by both successful SQL runs.
Local source hashes, commands, raw logs and review:
/tmp/mo-catalog-property-42-backport.YIYmmLMBon host50.The local checks establish the metadata invariant and branch compatibility;
they do not substitute for the original full distributed OOM acceptance.