Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Related incident #31888 and representation-cost issue #32426 do not independently track this confirmed repeated-property feedback mechanism.
Branch Name
main and 4.2-dev (also reproduced through SQL on the identified 4.2.1 hotfix).
Commit ID
Component reproductions: 2f6fcc772175d0c0e80ad97aac6d44360c513347 (Main), 260678bace0177678255089a23d0fe7d54cfc745 (4.2). SQL binary: e0e2308d074d84c507ce15352ffb0ea0405ab3b8. Current Main source check: 0c8bd5e5f3be4ce5582201513161181ddca37d6d.
Other Environment Information
Host50, Linux/amd64, isolated fresh single-process LOG/TN/CN for SQL verification. A 4 GiB / two-CPU container bounds the SQL test. Exact versions and evidence scope are given below.
Actual Behavior
Repeated in-place ALTER TABLE ... MODIFY COLUMN grows the persisted table constraint by writing catalog-derived properties back into StreamConfigsDef and appending another copy on the next catalog read. The table can remain empty, with an unchanged logical definition, while relkind and rel_createsql accumulate once per ALTER.
This is a confirmed metadata amplification defect affecting both Main and 4.2, investigated from #31888. It is not a claim that every part of the production OOM, or the different RSS headroom between Main and 4.2, is now explained. Please keep #31888 open for its original workload/availability acceptance.
Steps to Reproduce
On an isolated local single-process LOG/TN/CN instance:
CREATE DATABASE catalog_property_repro;
CREATE TABLE catalog_property_repro.events(col1 INT PRIMARY KEY, col2 INT);
-- Execute this identical statement 100 times, with autocommit enabled:
ALTER TABLE catalog_property_repro.events MODIFY col2 VARCHAR(25) NOT NULL;
SELECT rel_version, LENGTH(`constraint`), LENGTH(rel_createsql)
FROM mo_catalog.mo_tables
WHERE reldatabase = 'catalog_property_repro' AND relname = 'events';
SELECT COUNT(*) FROM catalog_property_repro.events;
SHOW CREATE TABLE catalog_property_repro.events;
DROP DATABASE catalog_property_repro;Actual SQL binary: v4.2.1-hotfix-20261030, revision e0e2308d074d84c507ce15352ffb0ea0405ab3b8, Go 1.26.4. Binary SHA256: 90d165bb2aa8c752cceeca9fddac99291cf14bd587a3e075ba81a3649ec2742a. Fresh data, 4 GiB memory cap, two CPU, no external data or cloud services.
| Completed MODIFY statements | rel_version | Persisted constraint bytes | rel_createsql bytes |
|---|---|---|---|
| 0 | 0 | 148 | 73 |
| 1 | 0 | 244 | 168 |
| 10 | 9 | 2,188 | 168 |
| 100 | 99 | 21,448 | 168 |
The first INT-to-VARCHAR conversion uses the copy path; the subsequent identical statements use the in-place path. Decoding the final persisted HEX(constraint) with the repository's ConstraintDef.UnmarshalBinary gives 200 properties: 100 relkind and 100 rel_createsql. Final row count is zero and SHOW CREATE remains correct. A separate widening control (VARCHAR(10) through VARCHAR(110), explicit ALGORITHM=INPLACE) also grows its constraint from 153 to 12,871 bytes.
Exact-revision component validation
The original repository functions were also tested independently at:
- 4.2 issue revision:
260678bace0177678255089a23d0fe7d54cfc745. - Main:
2f6fcc772175d0c0e80ad97aac6d44360c513347.
The test calls cache.getTableDef -> plan.DeepCopyTableDef -> engine.PlanDefToCstrDef -> ConstraintDef.MarshalBinary/UnmarshalBinary; it does not reimplement those functions. With a fixed 257-byte CreateSQL, both revisions produce:
| Feedback rounds | Planner properties | Constraint bytes |
|---|---|---|
| 0 | 2 | 330 |
| 1 | 4 | 633 |
| 10 | 22 | 3,360 |
| 100 | 202 | 30,630 |
| 1,000 | 2,002 | 303,330 |
The decode-only control stays at two properties / 330 bytes. Each test terminates successfully within its bounded local budget. Main SQL execution is not claimed by this component result. The relevant production path remains present in current Main 0c8bd5e5f3be4ce5582201513161181ddca37d6d (source verification).
Additional information
Root cause and ownership
disttae/cache.getTableDefunmarshals persisted constraints and appendsStreamConfigsDef.Configsto the planner properties.- It appends the authoritative catalog
relkindandrel_createsqlagain.txnTable.GetTableDefhas the equivalent projection path. - In-place ALTER preserves these properties through
DeepCopyTableDef. engine.PlanDefToCstrDefserializes all of them into anotherStreamConfigsDef.- Replace-definition processing persists the enlarged constraint. The next catalog generation repeats the loop.
Source references, pinned to current Main:
- Catalog projection
- Transaction-local projection and ALTER
- Planner-to-constraint conversion
- In-place ALTER compiler
Catalog GC cannot prevent a current definition from carrying all prior duplicate properties. Retaining many valid historical DDL versions additionally multiplies their cost; changing the retention window is not necessary to fix this defect. This is not evidence that objects remain incorrectly referenced after their allowed lifetime.
Relationship to the production incident
#31888 profiles are dominated by ParseTablesBatchAnd, Property.Unmarshal, ConstraintDef.UnmarshalBinary and getTableDef. The confirmed growth mechanism is consistent with these allocations. A newer 4.2 run 42640783596 again OOMs during MODIFY, before its account-concurrency phase. A Main control 42239771183 has similar Catalog-dominated heap growth but does not OOM in that interval. Main is therefore not immune to this defect merely because it has more RSS headroom in that sample.
The exact first introducing commit is not established. The feedback path already exists at v4.2.1; this must not be presented as a newly proven 4.2.6 regression. #32426 tracks a separate catalog replay/batch representation cost, not this repeated property feedback.
Expected Behavior
- Repeated decoding/ALTER/persistence of an unchanged logical table must keep projected properties and serialized constraints bounded.
- Historical repeated copies must not continue propagating through subsequent ALTER.
- Preserve authoritative catalog kind/CreateSQL/comment, arbitrary legitimate properties, PK/FK/index constraints and existing binary format.
- Do not mutate shared cached definitions, shorten MVCC retention, change admission/memory limits, or add a new cache/controller to solve this local ownership error.
- Add deterministic old-fails/new-passes component coverage, public SQL regression and metadata/constraint compatibility controls. Verify locally on Main before submitting the fix.
- A bounded local regression pass establishes this metadata fix, not full closure of the original 55 GiB distributed OOM.
Activity
fix(catalog): prevent property amplification across ALTER rewrites (#…
XuPeng-SH commentedon Nov 10, 2026
QA 交接:#32465 已于 2026-11-10 11:14:45 UTC 合入 main,merge SHA
5318305e0269c254b8ea22be7ddc2c430f3e73f8(PR head118beafafd6b1ca6fc0b9eaf53739d61fb044f6f)。本项按已合并的属性膨胀修复转测,不代表验收通过。范围:最终 diff 在 cache.getTableDef 和 txnTable.GetTableDef 两处复用同一过滤 helper,仅阻断持久化配置中 relkind / rel_comment / rel_createsql 的重复反馈,由 catalog 列提供当前权威值(含空值);其他属性的顺序、重复键和独立 PK/FK/index 约束保持。当前完整 issue/PR 讨论和 review threads 未见适用于此修复的已验证反例或未完成开发 follow-up。
已有证据(作者/评审报告,本轮未本地执行):host50 上旧源码覆盖后的回归在运行期失败,修复后三个 owning package 与增量 vet/lint 通过;正常比较模式 BVT 两轮各 21/21,100 次相同 MODIFY 后约束大小在第 1/10/100 轮均为 298 字节,另有持久化单行重启检查及清理记录。评审记录引用的是较早 head de790f3 的成功 CI;最后 head 118beaf 的 Mergify 记录为因 fork 编辑权限退出队列,不能将那条记录或较早 CI 冒称最终 merge SHA 的完整 CI 已通过。
建议 QA 在包含上述 merge SHA 的 main 上复测:新表及含历史重复属性的表连续 ALTER 后元数据有界;空/更新后的 comment/CreateSQL 权威值、合法自定义重复属性和顺序;PK/唯一键/FK 拒绝控制、SHOW CREATE/行数据,以及重启后再次 ALTER。遵循现有停机升级流程,旧 CN 仍执行旧逻辑时可能重新写入重复项。
未测边界:本轮未独立读取 host50 原始日志或运行 Go/SQL/分布式压力测试。此修复不立即清除全部历史元数据,不改变 GC 保留、内存限制或准入;#31888 的原始 55 GiB 分布式 OOM/可用性验收仍保留研发,不能由这组局部结果替代。#32426 的表示成本问题也不在本项闭环内。
[4.2-dev] fix(catalog): prevent property amplification across ALTER r…