Repository navigation
fix: preserve tombstones across lineage snapshot advances - #29539
Conversation
PR Summary by QodoPreserve tombstones across lineage snapshot advances
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
Commit review: c4647c0
结论:未发现阻塞性问题,建议合并。此为作者账号提交的 commit-bound COMMENT,不构成独立人工 APPROVE。全部 7 个文件及相关调用/回滚/提交路径已审查,未启用 subagent。Base/merge-base: 6d4957b395df919d201cc84ae60e40bb7b637657。
设计、实现和成本
- 不变量:RC 快照暴露 TN flush/merge 后的新 Rowid 前,事务删除记录必须同步迁移;迁移后不能只恢复 operator 时间戳。
- 第一职责归属仍是
Workspace.AdvanceSnapshot/disttae workspace。共享 lineage helper 只统一物理时间边界和错误检查,没有新增迁移执行路径、状态机、缓存、后台任务或持久格式。 - frontend CLONE/SNAPSHOT/内部 PITR 与 COPY ALTER/TRUNCATE 接入已有 workspace 路径;ALTER/TRUNCATE 删除不完整的 timestamp-only rewind。保留租户上下文缺失时的原有 frontend 路径、
updated physical - 1ns历史边界及 publication write barrier。普通非临时表的 pessimistic RC COPY ALTER/TRUNCATE 也走该路径,不能把成本只归于已有 branch 的表。 - 生产代码 +52/-57,净 -5;测试 +161/-27,净 +134;文档文件无增量。新 helper 复用已有接口,边界/错误表驱动测试、compiler 接线测试与 engine 真正可见性测试各有独立职责。新增 engine 场景复用现有 20 行 forced-flush fixture,无新增 cluster fixture 或生产测试 hook。
- 每次显式推进包含两次 workspace write-entry 遍历,以及相关表的对象变化检查;搬迁命中后才执行 Rowid transfer/持久 tombstone 的读取和重写。成本涉及整个事务 workspace,也可能来自其他表。已有 lastTransferred 限定迁移区间;未增加普通 SELECT/DML 调用入口或全局锁。没有规模基准,不能承诺大事务尾延迟影响很小。
本轮 QA(当前提交、darwin/arm64、Go 1.26.4、CPU)
原生输入与已验证 donor 一致,libmo SHA256 相同;当前提交 binary 构建 exit 0。验证过程未修改 PR 的生产/提交测试源码,额外挑战代码为临时 review artifact。
- helper、compiler consumer、disttae snapshot branch focused tests exit 0。
- 完整
pkg/frontend/pkg/frontend/databranchutils/pkg/sql/compile各一次-race,exit 0。 - engine 真实 forced-flush 的删除保留、重复推进、提交、事务回滚、语句回滚及立即提交矩阵
-race,exit 0(18.744s)。 - 额外白盒负对照:两种 tombstone 模式下裸
TxnOperator.UpdateSnapshot均复活 10 条已删除行;同一状态通过共享 workspace helper 后为 0 行。exit 0。 - 额外失败挑战:在 UpdateSnapshot 成功事件后取消上下文,使迁移返回
context canceled;语句回滚后立即 COMMIT,先前 DELETE 的最终持久结果仍正确。两种模式均通过;按单次 1.78s 推导-race -count=16(32.969s),exit 0。 - 完整原始
TestDataBranchPick -race,包含accept_mixed_update_and_insert、冲突策略、mixed INSERT/UPDATE/DELETE 与拒绝场景,exit 0(22.921s)。 - 当前 binary 的干净 1-CN/TN 服务公开 SQL:跨表 UPDATE+flush+重复 ALTER+COMMIT;DELETE+重复 ALTER+ROLLBACK;PITR+autocommit OFF+自己写入可见;branch TRUNCATE 与历史源;SNAPSHOT registry 单行。独立检查准确结果、唯一性、数据及 schema,全部通过。
- 额外公开 unhappy:COPY ALTER 已推进快照后拒绝 drop/add 同名列;随后 COMMIT 保留此前另一表的 DML,目标 schema/data 不变,通过。数据库/snapshot 清理均为 0;自建服务已停止。
- committed diff whitespace 检查通过。
评论、CI 与边界
读取时无人工 review、inline 评论或待解决线程。Qodo 有未完成 review 的提示及摘要,不能将其视为通过的独立审查。CI preflight 已通过,其余运行中任务没有等待、没有算作通过。
没有单独强制多表迁移到一半后注入存储 I/O 错误,也未进行规模/尾延迟基准;取消挑战证明的是 snapshot 已推进后的错误恢复,不能代替所有部分 I/O 失败。公开 SQL 未强制 mid-PICK flush;确定性 engine 白盒对照与真实完整 PICK 提供不同的验证职责。
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
The pre-copy lineage snapshot advance went through the workspace-owned AdvanceLineageSnapshot, but alterTableCopy still rewound only the transaction timestamp when it returned. After Workspace.AdvanceSnapshot relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and the snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML in the same transaction — the exact defect main removed in matrixorigin#29539, reintroduced when the advance moved before physical preparation. Remove the rewind and retain the workspace-owned advanced snapshot on every return path, matching the databranchutils.AdvanceLineageSnapshot contract. The duplicated isTemp/non-temp advance branches collapse into one mode-gated call. Tests: the compile root fails if ALTER COPY ever calls SetSnapshotTS after a workspace advancement (verified by mutation in both directions) and asserts retention across advance-failure and physical-copy-failure returns; a pessimistic-RC integration test keeps DN-flush-relocated in-memory deletes deleted across the ALTER COPY return boundary.
### Design record
- Added versioned design: `docs/design/20261010-alter-copy-pre-publication.md`.
- The design records the speculative-preparation/publication split, authoritative after-copy source-frontier revalidation, persisted-delete coverage, actual nested lock state, terminal retry and whole-transaction rollback ownership, transaction-local relation and workspace-write handling, alternatives, compatibility, source-state cost model, and validation map.
- Independent design approval of that exact revision is still required before implementation approval.
### Root cause
`ALTER TABLE ... COPY` acquired the transaction-scoped global SNAPSHOT lineage-owner gate before temporary-table creation, physical row copy, auto-increment reconciliation, and unaffected-index cloning. Every independent branch ALTER therefore held the stable `mo_catalog.mo_feature_registry` row for `SNAPSHOT` until commit. Under the reported 500-worker workload, unrelated ALTERs serialized behind each other and eventually returned MySQL 1205 lock-wait timeouts or MySQL 2013 connection losses.
Moving physical work before that gate also exposed correctness obligations:
- ALTER must not hold source locks while waiting for the lineage gate.
- Unlocked preflight must not take authoritative owner-row locks.
- Publication must reject source replacement, same-ID schema changes, row changes, and lineage-state changes that happened during physical preparation.
- If a concurrent same-table ALTER removes an index table between preparation and resolution, missing metadata must become a controlled definition-change retry rather than a nil-pointer panic.
### Exact changes
- Split unlocked lineage inspection and timestamp selection from authoritative, gate-protected lineage preparation in `pkg/sql/compile/alter.go`.
- Run lock-free temporary-table creation, physical row copy, auto-increment reconciliation, and unaffected-index cloning before acquiring the global lineage-owner gate. The temporary CREATE passes `WithDisableLock`, so it does not retain the source database shared lock or temporary target table exclusive lock.
- Acquire the lineage gate before source database, catalog-table, and physical-table locks. Existing upstream TRUNCATE behavior already uses compatible ordering; the existing TRUNCATE interleaving test is updated to observe physical work before the gate and gate acquisition before source locks.
- Preserve late broad admission after rebase onto `4022729da2`, while adopting upstream's `admitBroadTableLifecycleRC` API and logical-ID-aware historical-source probes.
- After gate acquisition, advance the RC snapshot, re-resolve the source, and reject source-ID replacement, same-ID table-definition-version changes, source data changes since copy, foreign-key state changes, stale lineage, late historical ownership, and same-statement lineage column replacement before publication.
- Preserve the physical-copy timestamp when lineage becomes relevant only during late publication.
- Replace the post-copy CDC handle probe with `SourceCommitTSAfterCopy(copyTS)`. It uses the authoritative partition-state frontier, excludes only current-transaction workspace writes, includes in-memory rows, data objects, and persisted tombstone objects, fails closed for unavailable providers, and short-circuits once a source frontier exceeds the copy timestamp.
- Aggregate `SourceCommitTSAfterCopy` across every combined partition member, short-circuiting after any member exceeds the copy timestamp and failing closed for missing member providers; a local write on one member no longer suppresses checks for other rows or partitions.
- Convert post-physical source replacement, definition-version, source-data, lifecycle-admission-retry, and source-lock-refresh races to terminal `ErrTxnWriteConflict`; RC statement retry therefore cannot repeat physical preparation while retaining locks. The frontend classifies this conflict as a whole-transaction rollback in both autocommit and explicit-transaction mode.
- Convert a nil source-index object or definition returned by unlocked `Resolve` into `ErrTxnNeedRetryWithDefChanged`, preventing the CI-observed stale-index-generation panic.
- Add the optional `RelationCreatedInCurrentTxn` and after-copy source-frontier relation capabilities with disttae primary, combined-table, and delegate implementations. Relation-created sources skip the committed probe; existing relations with local writes still check committed mutations from other transactions.
- Add deterministic source-lock retry coverage for optimistic ALTER, catalog-table contention, and physical-table contention.
- Update the concurrent stale-index integration test to require terminal error 20601 for a post-copy source-admission race, explicitly retry that statement in a new transaction, and retain the final schema/index/default assertions.
### Issue-to-test proof
- Independent ALTERs no longer serialize: `TestAlterCopyPhysicalWorkDoesNotWaitForLineageOwnerGate` proves both independent physical inserts start while the lineage gate is held elsewhere.
- Lifecycle lock order is acyclic: `TestAlterCopyAndDropUseGateBeforeSourceLocks`, `TestAlterCopyAndTruncateUseGateBeforeSourceLocks`, and `TestAlterCopyAndTruncateSerializeBeforeTableLocks` prove ALTER physical work starts before the gate and both ALTER and TRUNCATE record gate acquisition before source locks.
- Source-lock retry contracts are explicit: `TestLockAlterCopySourceRetryContracts` proves optimistic transactions take no source locks, while catalog-table and physical-table retry errors are converted to `ErrTxnNeedRetryWithDefChanged`.
- Unlocked preflight is read-only and race-safe: `TestInspectAlterDataBranchLineageSeesBranchCreatedAfterPreflight` and `TestAlterTableHasLatestHistoricalBranchSourceUsesFreshUnlockedProbe` prove a late branch is rediscovered by authoritative postgate preparation.
- Stale-copy protection is terminal: `TestAlterCopyRejectsSourceReplacementAfterGate`, `TestAlterCopyRejectsSourceDataChangeAfterCopy`, and `TestAlterCopyRejectsSameIDSourceDefChangeAfterGate` reject replacement, row changes, and same-ID definition changes before publication.
- Missing index metadata is controlled: `TestCloneUnaffectedIndexesRetriesWhenSourceIndexDisappears` proves the definition-change retry path instead of a nil dereference.
- Publication and rollback remain correct: `TestAlterCopyLateLineagePublicationUsesCopyTimestamp`, `TestAlterCopyFailsAfterPhysicalWorkWithoutReleasingGate`, and same-statement replacement coverage verify the original timestamp, injected failure, and no publication after stale-copy discovery.
- Transaction-local state is handled explicitly: `TestAlterCopySkipsSourceChangesForRelationCreatedInCurrentTxn` skips the probe only for relation-created sources, while `TestAlterCopyChecksCommittedChangesDespiteTransactionLocalWrites` proves local writes do not suppress another transaction's committed change. `SourceCommitTS` itself still fails closed for async-index callers.
- Nested CREATE does not retain catalog locks: `TestAlterCopyCreateOptionsDisablesNestedCreateLock` proves `WithDisableLock`.
- The source frontier is bounded and authoritative: `TestAlterCopySourceChangedSinceCopyUsesSourceCommitTS` and `TestAlterCopySourceChangedSinceCopyFailsClosedWithoutProvider` cover unchanged, changed, and unavailable states; `TestSourceCommitTSAtIncludesPersistedTombstone` proves a persisted DELETE advances the frontier.
- Partition aggregation is correct: `TestCombinedTxnTableSourceCommitTSReturnsMax`, `TestCombinedTxnTableSourceCommitTSShortCircuits`, `TestCombinedTxnTableSourceCommitTSFailsClosedForMissingProvider`, and `TestCombinedTxnTableSourceCommitTSPropagatesMemberError` cover member maxima, short-circuiting, and fail-closed behavior.
- Terminal conflicts do not enter RC statement retry: `TestAlterCopyPostPublicationConflictIsNotStatementRetryable` checks both `isRetryErr` and `canRetry`.
- The reported concurrency shape passes: 500 independent branch tables and 500 concurrent ALTER sessions complete with zero lock-wait and zero connection-loss failures.
### Reproduction
- Issue baseline at `77dbf5464466b1d5ae784e7d17d92cd1c1c8d17d`: 301/500 workers completed, 199/500 failed, 172 failures were MySQL 1205, and 27 failures were MySQL 2013.
- Deterministic pre-fix ALTER ablation: replacing only `pkg/sql/compile/alter.go` with its base-compatible version causes `TestAlterCopyPhysicalWorkDoesNotWaitForLineageOwnerGate` to time out while both independent physical inserts wait behind the global lineage gate.
- CI regression: old run `37943988958` panicked in `constructTableClone` from `cloneUnaffectedIndexes` during `TestIssue277xxDDLConsistency/27725_concurrent_alter_retries_a_stale_physical_index_generation`. The missing-index retry guard and exact integration test now pass.
- Definition-guard ablation: removing only the postgate definition-version comparison causes `TestAlterCopyRejectsSameIDSourceDefChangeAfterGate` to lose the expected retry error.
- Real workload: 500 workers, 500 independent branch tables, a one-row base, and a 120-second command timeout completed in 71.995 seconds with 500/500 successful ALTERs, 500/500 observed columns, 0 failed ALTERs, 0 MySQL 1205 errors, 0 MySQL 2013 errors, and successful database cleanup (`/tmp/mo-29208-concurrency-500-revision-r6.out`).
- Source-frontier cost: `BenchmarkSourceCommitTSAtUnchanged250KObject` modeled one unchanged 250,000-row non-appendable object with a threshold after every row commit and measured `44075 ns/op`, `1125 B/op`, and `4 allocs/op` on Apple M5 (`darwin/arm64`, 10 GOMAXPROCS).
### Tests
- Previous review-response, CI-regression, and rebase validation on head `104cac3d12`:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=1200s ./pkg/sql/compile ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/logtailreplay`
— passed after the rebase onto `42d42546fd2c2b2449cb81cea47f81d300139753`: compile in 18.925s, disttae in 11.943s, and logtailreplay in 8.386s.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s -run '^TestIssue27055DatabaseCloneReadsExplicitTransactionSource$' ./pkg/tests/issues`
— passed in 13.087s after the transaction-local workspace-write fix.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^(TestTxnTableHasTransactionLocalWrites|TestCombinedTxnTableHasTransactionLocalWritesShortCircuits|TestAlterCopySkipsSourceChangesForTransactionLocalWrites)$' ./pkg/vm/engine/disttae ./pkg/sql/compile`
— passed in 1.370s and 1.403s.
- Rebase integration on `433a8dc26c`:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile`
— passed in 15.293s.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/vm/engine/disttae ./pkg/vm/engine`
— passed in 9.901s and 1.537s.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s -run '^(TestIssue277xxDDLConsistency|TestIssue29400CopyAlterRetainedGatePromotionFastFails)$' ./pkg/tests/issues`
— passed in 18.517s.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s ./pkg/frontend ./pkg/sql/plan`
— passed in 37.126s and 36.724s.
`gofmt -l`, `git diff --check`, and `git status --porcelain=v1 -uall` — clean.
- Exact CI regression:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue277xxDDLConsistency/27725_concurrent_alter_retries_a_stale_physical_index_generation$' -v ./pkg/tests/issues`
— passed in 11.668s on the latest rebased head.
- Exact-head focused closure:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^(TestCloneUnaffectedIndexesRetriesWhenSourceIndexDisappears|TestAlterCopyAndTruncateSerializeBeforeTableLocks|TestIssue277xxDDLConsistency/27725_concurrent_alter_retries_a_stale_physical_index_generation)$' ./pkg/sql/compile ./pkg/tests/issues`
— compile tests passed; the exact integration subtest was rerun explicitly as above.
- Coverage-closing lock contracts on `e3de6b6204`:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -run '^TestLockAlterCopySourceRetryContracts$' ./pkg/sql/compile`
— passed.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^(TestAlterCopyPhysicalWorkDoesNotWaitForLineageOwnerGate|TestAlterCopyAndDropUseGateBeforeSourceLocks|TestAlterCopyAndTruncateUseGateBeforeSourceLocks|TestAlterCopyFailsAfterPhysicalWorkWithoutReleasingGate|TestAlterCopyLateLineagePublicationUsesCopyTimestamp|TestAlterCopyRejectsSourceReplacementAfterGate|TestAlterCopyRejectsSourceDataChangeAfterCopy|TestAlterCopySkipsSourceChangesForRelationCreatedInCurrentTxn|TestAlterCopyRejectsSameIDSourceDefChangeAfterGate|TestAlterCopyRejectsSameStatementReplacementDiscoveredAfterGate)$' ./pkg/sql/compile`
— passed.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -coverprofile=<profile> -run '^TestLockAlterCopySourceRetryContracts$' ./pkg/sql/compile`
— passed; the profile records executions of `alter.go` blocks `1187`, `1199`, and `1210`, the three previously uncovered changed blocks that caused the 73.61% PR coverage result.
- Full owning package:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile`
— passed in 14.577s on the rebased head `e3de6b6204`.
- Adjacent engine packages:
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/vm/engine/disttae`
— passed in 7.745s.
`.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/vm/engine`
— passed in 0.827s.
- Race stress:
`.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=10 -timeout=300s -run '^(TestAlterCopyPhysicalWorkDoesNotWaitForLineageOwnerGate|TestAlterCopyAndDropUseGateBeforeSourceLocks|TestAlterCopyAndTruncateSerializeBeforeTableLocks|TestCloneUnaffectedIndexesRetriesWhenSourceIndexDisappears)$' ./pkg/sql/compile`
— passed in 4.688s.
- Static validation:
`GOWORK=off CGO_CFLAGS="-I<cgo> -I<thirdparties>/include" go vet -mod=readonly ./pkg/sql/compile ./pkg/vm/engine ./pkg/vm/engine/disttae`
— passed.
- Build:
`make build` — passed; only the existing duplicate-library linker warning was emitted.
- BVT:
`cd /tmp/mo-29208-bvt-r3 && bash /Users/ghs-mo/MOWorkSpace/mo-tester/run.sh -n -p <worktree>/test/distributed/cases/ -i diff_schema_evolve,merge_schema_evolve,alter_table_historical_lineage`
— 492/492 passed: `diff_schema_evolve` 278/278, `merge_schema_evolve` 139/139, and `alter_table_historical_lineage` 75/75.
- Real concurrency:
`ulimit -n 2048 && python3 /tmp/mo-29208-concurrency-500.py`
— 500/500 successful ALTERs, 500/500 columns verified, 0 failures, 0 MySQL 1205, 0 MySQL 2013; database dropped.
- Final hygiene:
`gofmt -l` on the seven changed Go files, `git diff --check`, and `git status --porcelain=v1 -uall` — clean and limited to the focused seven-file scope.
The BVT and real-workload runs passed on this implementation before the latest rebase. The latest semantic rebase onto `f09d4788fd` applied cleanly; upstream changed unique-index duplicate precheck code in `pkg/sql/compile` and did not alter this PR's ALTER COPY production files. Latest exact-head validation on `79e45f24b5`:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s ./pkg/sql/compile` — passed in 16.208s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s -run '^TestIssue277xxDDLConsistency/27725_concurrent_alter_terminal_conflict_supports_external_retry$' ./pkg/tests/issues` — passed in 11.308s.
- `gofmt -l` on all changed Go files, `git diff --check`, and `git status --porcelain=v1 -uall` — clean and limited to the focused PR scope.
### Residual risk
- The global lineage gate remains intentionally serialized for atomic publication and genuinely conflicting owner operations; this PR narrows and orders the held section rather than removing the ordering guarantee.
- Future lifecycle owners that take both source locks and the lineage gate must preserve gate-before-source-lock ordering.
- Future lineage invariants must be added to the postgate revalidation path.
- The 500-session proof uses a one-row base to isolate the failing ALTER concurrency path; deterministic barriers and race tests provide the row-count-independent ordering proof. The full reported 250,000-row throughput workload was not rerun; the committed 250,000-row unchanged-object benchmark measures the new serialized source-frontier cost, and broader multi-object storage layouts remain a performance envelope to monitor.
- The old run's two Compose failures were infrastructure failures while pulling the `createbuckets` image (`unauthorized: access to the requested resource is not authorized`); no matching issue was found. The old `pr-size-label` failure was an unrelated runner-proxy TLS failure tracked by #27127.
### Current exact head: `cf9a1735b7`
Rebased onto current `main` `02a2823c20` and resolved both semantic rebase boundaries:
- kept pre-publication, unlocked ALTER COPY preparation;
- integrated upstream forward-FK admission by computing `replacementAdmission.createNames` before physical CREATE and passing that admission into nested `withDropLifecycle`;
- kept upstream frontend rollback classification and added `ErrTxnWriteConflict` to the whole-transaction rollback set.
The source mutation proof now closes both DELETE lifecycle counterexamples:
- retained tombstone entries, including soft-deleted objects, remain source-change proof; actual retention truncation is represented by the partition state-start floor;
- appendable tombstones read non-aborted per-row commit timestamps with the same snapshot semantics as the delete reader;
- non-appendable tombstones read per-block commit-ts zonemaps;
- unavailable tombstone files or commit-ts metadata fail closed;
- the unused public `RelationHasTransactionLocalWrites` chain was removed while preserving the private async-index local-write guard.
The concurrent ALTER integration test now distinguishes the newly upstream pre-copy FK name-pin fast-fail (`ErrLockConflict`) from terminal post-copy `ErrTxnWriteConflict`; both are externally retryable, and final schema/index assertions remain unchanged.
Latest exact-head local validation:
- `CGO_CFLAGS=... go test ./pkg/vm/engine/disttae/logtailreplay -run 'TestSourceCommitTSAt|TestMaxCommitTS' -count=1` — passed.
- `CGO_CFLAGS=... go test ./pkg/vm/engine/disttae ./pkg/sql/compile ./pkg/frontend ./pkg/common/moerr -run 'TestSourceCommitTS|TestCombinedTxnTableSourceCommitTS|TestTxnTableDelegateSourceCommitTS|TestAlterCopy|Test_isErrorRollbackWholeTxn|TestStaticRollbackSetIsInfrastructureOnly|Test.*Rollback.*Txn' -count=1` — passed before the final one-commit rebase; the production delta is unchanged by that test-only upstream commit.
- `CGO_CFLAGS=... go test ./pkg/tests/issues -run 'TestIssue277xxDDLConsistency/27725_concurrent_alter_conflict_supports_external_retry' -count=1` — passed on the exact final head.
- `git diff --check` — passed; the working tree is clean.
Freshness update: rebased exact head `cba088b792` onto `main` `02a2823c20`. The only new upstream commit changes join-expression ownership and has no file overlap with this PR. Revalidated on the exact head: focused logtail source-frontier tests, focused ALTER COPY compile tests, the concurrent ALTER integration test, and `git diff --check`; all passed.
### Coverage CI follow-up and rebase validation
Coverage run `38204952772` exposed one PR-owned test expectation and two unrelated upstream failures:
- `TestIssue29400CopyAlterRetainedGatePromotionFastFails/exclusive_gate` expected the competing ALTER to wait, but upstream pre-copy FK admission now fast-fails with `ErrLockConflict` when it meets the retained source lock. The test now accepts that expected conflict and proves the UPDATE owner can execute its next statement, commit value `2`, and complete the target `DROP TABLE` without deadlock.
- `TestPartitionTopNRejectsUnsupportedOrderType` is the existing clean-main issue #29968.
- `TestTruncateLifecycleRCWaitPolicy` is the existing clean-main issue #29971.
Exact-head validation:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s -run '^TestIssue29400CopyAlterRetainedGatePromotionFastFails$' ./pkg/tests/issues` — passed in 12.889s.
- `gofmt -w pkg/tests/issues/issue_29400_test.go`, `git diff --check`, and `git status --porcelain=v1 -uall` — clean before commit.
The branch already contained `main` `02a2823c20` for that test-only follow-up.
### Rebase onto `main` `7af631bdf7`
The exact head is now `cf9a1735b7`, rebased onto current `main` `7af631bdf7`. The rebase applied cleanly and incorporates the upstream fixes for the two clean-main coverage blockers:
- `TestPartitionTopNRejectsUnsupportedOrderType` (#29968) now passes on the rebased head.
- `TestTruncateLifecycleRCWaitPolicy` (#29971) now passes on the rebased head.
- The PR-owned `TestIssue29400CopyAlterRetainedGatePromotionFastFails` regression also passes after the rebase.
Exact-head validation:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s -run '^TestIssue29400CopyAlterRetainedGatePromotionFastFails$' ./pkg/tests/issues` — passed in 26.805s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s -run '^TestPartitionTopNRejectsUnsupportedOrderType$' ./pkg/sql/colexec/partition` — passed in 3.080s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s -run '^TestTruncateLifecycleRCWaitPolicy$|^TestAlterCopyAndTruncateSerializeBeforeTableLocks$' ./pkg/sql/compile` — passed in 3.543s.
- `gofmt -l` over all changed Go files, `git diff --check`, and `git status --porcelain=v1 -uall` — clean after the rebase.
### Review update and current exact head: `f8894b6a0f`
Rebased cleanly onto current `main` `11914526ba` and addressed the pessimistic-RC independent-ALTER publication finding:
- `admitReplacementNames` no longer runs before physical COPY preparation. Pessimistic-RC ALTER COPY now acquires the broad SNAPSHOT gate first, then pins replacement endpoint names with `WaitPolicy_Wait`.
- ALTER records the transaction's retained lock-table baseline before preparation. Gate waiting is permitted only when every retained lock table is new relative to that baseline and is certified by the workspace as created in the transaction. Pre-existing, source, catalog, or unprovable locks retain the fast-fail policy, preventing `G -> name -> G` reverse edges.
- Nested temporary CREATE and row copy propagate `WithDisableLock`; nested execution skips pre-pipeline metadata/table locks and lock operators. TRUNCATE keeps its existing fast-fail replacement-name policy.
- `TestIssue29400IndependentCopyAltersProgressInPessimisticRC` covers both a held explicit publisher and overlapping autocommit publishers. It uses separate connections, observes the independent ALTER waiting at the gate, proves it does not fail while the holder retains the gate, and proves both ALTERs finish after release.
- The exact-head validation passed for `./pkg/sql/compile` and `./pkg/tests/issues` with `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s`, including the new independent-publisher integration test. `gofmt -l` over changed Go files, `git diff --check`, and the final clean-tree check also passed.
- The versioned design and implementation now record this `G -> private preparation locks -> replacement names -> source` publication order and its liveness proof.
### Rebase onto `main` `b09f2c6fc5`
Rebased cleanly onto `main` `b09f2c6fc5` at exact head `3e5069423d`.
- The rebase introduced no semantic conflicts; the full PR delta remains scoped to the ALTER COPY publication lifecycle and its tests/design.
- Re-ran the full affected package set after the rebase:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile ./pkg/tests/issues ./pkg/frontend ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/logtailreplay`
- All five packages passed.
### Current exact head after the latest rebase: `2e45e40035`
Rebased cleanly onto current `main` `cd8d5abf96`.
- The rebase applied without conflicts. Its only overlapping paths with this PR were `pkg/sql/compile/compile.go` and `pkg/sql/compile/compile_test.go`, where upstream renamed the vector-index scan node; the ALTER COPY ownership changes remained semantically unchanged.
- Re-ran the focused affected package set after the rebase:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile`
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/tests/issues ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/logtailreplay`
- All four packages passed.
- `git diff --check`, `gofmt -l` over changed Go files, and the clean-tree check passed before push.
### Review update and exact head: `e088a231b9`
Rebased cleanly onto current `main` `175a645a85` and closed the unaffected-index preparation finding:
- The private ALTER-COPY temporary CREATE now opts out of transient index CDC and idxcron task registration. Because no transient tasks are registered, ALTER also skips their catalog cleanup; post-rename publication retains the existing final task-registration path. This removes the `mo_tables`/`mo_database` lock retention introduced by transient task cleanup while preserving final index-task ownership.
- IVF-FLAT `DeleteBeforeClone` now executes its private replacement hidden-table cleanup with `WithDisableLock`, so the nested DELETE acquires neither catalog metadata locks nor row locks.
- `TestIssue29400IndependentCopyAltersProgressInPessimisticRC` now enables `experimental_ivf_index`, creates an unchanged IVF-FLAT index, and covers both a held explicit publisher and overlapping autocommit publishers. The unrelated ALTER waits at the publication gate and completes after release.
- `TestAlterCopyCreateOptionsDisablesNestedCreateLock` asserts the new skip-registration option. `TestScopeAlterTableCopyInsertTmpDataPipelineFlush` now proves private preparation no longer calls `CopyTableDef` for transient task cleanup while retaining its nil-context pipeline-flush oracle.
- The versioned design records the lock-free cleanup and symmetric registration/cleanup policy.
Exact-head validation after the rebase:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400IndependentCopyAltersProgressInPessimisticRC$' ./pkg/tests/issues` — passed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s -run '^TestScopeAlterTableCopyInsertTmpDataPipelineFlush$' ./pkg/sql/compile` — passed.
- `gofmt -l` over all changed Go files, `git diff --check`, and `git status --porcelain=v1 -uall` — clean on the exact head.
Additional validation on the identical code before the unrelated one-commit rebase (`896fa84927` on `main` `3e50e1b32d`):
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/tests/issues` — passed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=600s -run '^TestIssue29400IndependentCopyAltersProgressInPessimisticRC$' ./pkg/tests/issues` — passed.
### Current exact head after latest rebase: `6596f9dc04`
Rebased cleanly onto current `main` `e5111936b9` after the PR was reported behind.
- `git range-diff` confirms all ten PR commits are patch-equivalent to the prior head `e088a231b9`; only their base changed.
- The worktree remained clean, and no PR code or tests were modified by this rebase.
- No new semantic validation is claimed for this commit-only rebase. The exact prior-head focused validations above remain the latest code-specific evidence.
### Current exact head after latest rebase: `abd5a45122`
Rebased onto current `main` `21f19ae063` after `main` advanced twice during the refresh:
- First rebased `6596f9dc04` onto `main` `6b0da62260` at `3574aa681f`; `git range-diff` confirmed all ten PR commits were patch-equivalent.
- After the push, the live PR snapshot showed `main` had advanced to `21f19ae063`. Fetched that base and rebased again to `abd5a45122`.
- `git range-diff` between the `3574aa681f` and `abd5a45122` ranges confirms all ten PR commits remain patch-equivalent. The new upstream commit overlaps this PR only in `pkg/sql/compile/compile.go`/`compile2.go`; the automatic rebase preserves both the ALTER private-preparation locking changes and upstream prepared zero-limit producer behavior.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400IndependentCopyAltersProgressInPessimisticRC$' ./pkg/tests/issues` — passed.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestPreparedZeroLimitReuse$' ./pkg/tests/sqlintegration` — passed.
- `gofmt -l` over changed Go files, `git diff --check`, protected-scope check, and the final clean-tree check passed on the exact head.
### Review update and current exact head: `7f243d2e4c`
Rebased onto current `main` `fcad62a8ff` and closed the Compile-pool registration-policy escape found in review `PRR_kwDOFEPiGM8AAAABR92hOw`:
- `Compile.clear` resets `skipIndexTaskRegistration` with the other per-statement flags (`disableLock`, `skipDataBranchReclaim`, `keepAutoIncrement`) before the object returns to the global reuse pool, and `NewCompile` re-initializes it. The ALTER COPY private-registration opt-out is now a property of the single private preparation generation and can no longer reach an unrelated later `CREATE TABLE` with an inline async/IVF index through pool reuse (`compile.go`).
- The intentional current-generation suppression is unchanged; the versioned design records the pool-boundary ownership of the opt-out (`docs/design/20261010-alter-copy-pre-publication.md`).
- `ignoreCheckExperimental`, the only other assigned-but-unreset sibling in `txnExecutor.Exec`, is pre-existing upstream state from #22428 and is currently assigned-but-never-read; it is outside this PR's introduced delta and left untouched.
Proof on the exact head:
- `TestCompileClearResetsSkipIndexTaskRegistration` exercises the pool reset directly; mutation-verified: removing only the `clear` reset makes it fail while the rest of the fix stays.
- `TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy` deterministically reproduces the review's Release -> same-object `NewCompile` pool handoff (single-P, GC disabled) and proves the next frontend Compile starts with the ordinary registration policy.
- `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation` proves, on one CN connection, that an ordinary inline IVF-FLAT `CREATE TABLE` registers its `mo_catalog.mo_index_update` `ivfflat_reindex` task before and after `ALTER ... ALGORITHM=COPY` private preparation, and that publication re-registers the replacement index's task.
Validation on the exact head:
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 27.431s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/vm/engine/disttae` — passed in 10.236s.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/vm/engine/disttae/logtailreplay` — passed in 27.991s.
- `- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=1800s ./pkg/tests/issues` — passed in 552.697s (177 tests, 0 failures; includes all `TestIssue29400*` roots and the new registration control). An earlier run of this suite on the same head failed once with a transient `internal error: cn service bootstrap` while the embedded cluster was starting; the identical rerun and every focused cluster test passed.`
- `gofmt -l` over changed Go files, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
CI-blocker follow-up: the tracked unrelated blocker #30047 (logservice `gossip_fixture_test.go` obsolete `randomPorts.allocate` signature failing UT/SCA/Coverage on run `38347106648`) was closed at `2026-10-13T08:30:47Z`; its fix landed on `main` in `35c8dd5854` and is incorporated by this rebase. This PR does not modify `pkg/logservice`. The push creates a new head and a fresh CI run; the stale failed run is not rerun.
### Current exact head after latest rebase: `4c5051fc77`
Rebased onto current `main` `5d971d07a7` after the PR was reported behind.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `7f243d2e4c`; only their base changed.
- The single new upstream commit `5d971d07a7` (empty indexed FK cascades / self-FK ALTER) touches `pkg/sql/plan` and BVT cases with no file overlap with this PR.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 16.425s; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 8.110s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `8e5c8b3b53`
Rebased onto current `main` `e17fc0f7fe` after the PR was reported behind again.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `4c5051fc77`; only their base changed.
- The two new upstream commits (`6ca4363a73` information_schema rewritten-column hiding, `e17fc0f7fe` prepared row-rule invalidation) touch `pkg/sql/plan`, `pkg/frontend` production files, and BVT cases with no file overlap with this PR.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 19.691s; the focused frontend rollback-classification tests this PR extends (`Test_isErrorRollbackWholeTxn`, `TestStaticRollbackSetIsInfrastructureOnly`, and the surrounding rollback roots) — passed in 2.152s; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 9.078s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `60e84f43df`
Rebased onto current `main` `c4a210802d` after the PR was reported behind again.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `8e5c8b3b53`; only their base changed.
- The four new upstream commits (`5652252431` window hash partitioning, `959d12d3b9` Starlark NULL boundary, `838bf5d1f8` docs MO-scan branch, `c4a210802d` Iceberg adapter module tidy) have no file overlap with this PR's source or test files; the Iceberg commit's workflow change is upstream-owned and untouched here.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 18.864s; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 8.837s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `cd2c40fd52`
Rebased onto current `main` `a53390c57d` after the PR was reported behind again.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `60e84f43df`; only their base changed.
- The two new upstream commits are `ec7a910a02` (TIME assignment bounds for external LOAD) and `a53390c57d` (BuildJsonPlan statistics snapshot race). The LOAD commit also touches `pkg/sql/compile/compile.go` in the extern-scan region; the rebase auto-merged it with this PR's `NewCompile`/`clear` flag changes, and both `skipIndexTaskRegistration` resets are verified present on the exact head (compile.go:161 and compile.go:571).
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 14.119s (includes `TestCompileClearResetsSkipIndexTaskRegistration` and `TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy`); `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 7.801s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `f796e46fb0`
Rebased onto current `main` `071a79b77f` after the PR was reported behind again.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `cd2c40fd52`; only their base changed.
- The single new upstream commit `071a79b77f` (preserve row rewrite rules through CTAS) touches `pkg/sql/compile/ddl.go` (`populateCreatedTable`, CTAS INSERT privilege region) and `pkg/sql/compile/sql_executor.go` (rewrite-option attachment in `txnExecutor.Exec`), both outside this PR's hunks; the rebase auto-merged and all three `skipIndexTaskRegistration` sites are verified present (compile.go:161, compile.go:571, sql_executor.go:618).
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 16.696s (includes both pool-boundary regression tests); `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 8.558s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `ad74f1e810`
Rebased onto current `main` `5a0570ea70` after the PR was reported behind again.
- `git range-diff` confirms all eleven PR commits are patch-equivalent to the prior head `f796e46fb0`; only their base changed.
- The three new upstream commits (`2e139d84bf` Kafka Connect recovery qualification harness, `ac98d7bd1f` scalar DESCRIBE view reflection coverage, `5a0570ea70` docs/skills template validation) are test/documentation changes with no file overlap with this PR.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — passed in 23.443s (includes both pool-boundary regression tests); `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — passed in 8.945s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Review update and current exact head: 173bf86f72
Addresses aptend's test-reliability P2 from the deep re-review of `ad74f1e810e2d1b6c360129e326155dc3fa4875c` (that review closed the previous P1 pool-leak blocker and substantiated no further production blocker). The P2: the new pool-handoff regression asserted `sync.Pool` pointer identity, which the pool's documented contract and the race runtime do not support — `Put` drops values with probability 1/4 under the race detector — so the canonical `-race -count=100` validation could fail randomly on a correct implementation (19/100 on the reviewer's run, reproduced locally at compile_test.go:203).
This cycle adds one commit, test-only. At commit time `main` was unchanged (`5a0570ea70083c9365719009a5ed8d7618f9ed91`); it advanced to `55a019f0b0` during validation, so this commit was then rebased before pushing - see the rebase section below for the patch-equivalence record.
- `TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy` is now a drop-tolerant, policy-based oracle. Each of 16 rounds seeds the exact leak payload through the real boundary — private executor `Compile` with its executor-set policy, `Release` (`Compile.clear` then `sync.Pool.Put`) — and requires the ordinary registration policy on the frontend `Compile` constructed next by the public `NewCompile`, whichever object the pool returns. Pointer identity is only logged; a legitimate pool drop can never fail the root. Drops cannot mask a leak: inheritance requires a `Put` the pool kept, every kept seed is asserted on the immediately following construction, and with both reset layers present the root is green by construction.
- Non-masking is verified by mutation: with both the `clear()` reset and the `NewCompile` init removed, the root fails deterministically without `-race` at round 0, and fails all 3 invocations with `-race -count=3`; with the resets present, the canonical race command is fully green. The `clear()` reset layer keeps its deterministic, pool-free probe `TestCompileClearResetsSkipIndexTaskRegistration` (removing only the `clear` reset still fails it).
- Exact-head revalidation: `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` — PASS 8.500s (100/100); the same command without `-race` — PASS (7.344s); full `./pkg/sql/compile` package - PASS 18.046s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Rebase onto current main: `173bf86f72` (`173bf86f7228cfc5c3ac604294e2581803ee4294`)
`main` advanced from `5a0570ea70` to `55a019f0b0` during the validation above, so the branch was rebased before pushing.
- `git range-diff` confirms all twelve PR commits (the eleven prior patches plus the new drop-tolerant handoff test) are patch-equivalent to the pre-rebase head `01fb35bb3a`; only their base changed.
- The three new upstream commits (`944b721d1b` JOIN reset buffers across execution generations — `pkg/sql/colexec/{dedupjoin,hashjoin,indexjoin,loopjoin}`, `821250ea88` recursive-CTE test cases, `55a019f0b0` canonical collation admission tests) have no file overlap with this PR; the rebase auto-merged.
- Exact-head revalidation after the rebase: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — PASS in 18.046s (includes both pool-boundary regression tests); `.agents/skills/mo-dev/scripts/mo-cgo-test -race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` — PASS in 8.500s, no failure in 100 runs; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — PASS in 18.363s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `2990b63c36` (`2990b63c36c8cd5d6c652f8927503af2a95361cd`)
Rebased onto current `main` `b2e8bc4789` after `main` advanced again while the previous section was being pushed (`55a019f0b0` -> `b2e8bc4789`).
- `git range-diff` confirms all twelve PR commits (the eleven prior patches plus the drop-tolerant handoff test) are patch-equivalent to the prior head `173bf86f7228cfc5c3ac604294e2581803ee4294`; only their base changed.
- The single new upstream commit `b2e8bc4789` (remap reused CTE readers after projection pruning) touches `pkg/sql/plan/{cte_reuse.go,query_builder.go}` plus CTE test cases, with no file overlap with this PR; the rebase auto-merged.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — PASS in 25.422s (includes both pool-boundary regression tests); `.agents/skills/mo-dev/scripts/mo-cgo-test -race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` — PASS in 8.389s, no failure in 100 runs; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — PASS in 8.846s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head.
### Current exact head after latest rebase: `0ed0f79634` (`0ed0f79634b20a0f8b8c74d525f91999dc4cd3f1`)
Rebased onto current `main` `fab7b5c043` after the behind event (head `2990b63c36` was reported behind `main` advanced `b2e8bc4789` -> `fab7b5c043` shortly after the previous cycle's push).
- `git range-diff` confirms all twelve PR commits (the eleven prior patches plus the drop-tolerant handoff test) are patch-equivalent to the prior head `2990b63c36c8cd5d6c652f8927503af2a95361cd`; only their base changed.
- The single new upstream commit `fab7b5c043` (preserve join predicate ownership during reordering, #30056) touches `pkg/sql/plan/associative_law.go` plus a plan regression test, with no file overlap with this PR; the rebase auto-merged.
- Exact-head revalidation: `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s ./pkg/sql/compile` — PASS in 14.853s (includes both pool-boundary regression tests); `.agents/skills/mo-dev/scripts/mo-cgo-test -race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` — PASS in 10.348s, no failure in 100 runs; `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run '^TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation$' ./pkg/tests/issues` — PASS in 7.680s (first invocation of this root during the cycle aborted with `[build failed]`: the Go linker could not reopen cached cgo objects after a build-cache eviction; the identical command was rerun and passed in 7.680s, so the abort was a toolchain cache eviction, not a test failure).
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `16023e02d6` (`16023e02d691abaa1e46fc0481d40cc0509c1c2e`)
Rebased onto current `main` `51300cbd01` after the behind event (head `0ed0f79634` was reported behind; `main` advanced `fab7b5c043` -> `51300cbd01`).
- The single new upstream commit `51300cbd01` (prevent table rename from bypassing role row filters, #29186) is the first upstream commit during this PR's life that also modifies this PR's main production file: `pkg/sql/compile/alter.go` (+183 — new `checkRoleRuleRenameAdmission*` admission gates at the `Scope.RenameTable` entry and the rename-action path of `Scope.AlterTable`, plus new `role_rule_lifecycle.go`), `alter_test.go`, `types.go` (new `Scope.roleRuleRenameAdmissionChecked`), frontend rename/rewrite-rule files, and two `pkg/tests/issues` roots.
- The rebase auto-merged. Semantic integration verified: the rename admission is orthogonal to this PR's ALTER COPY lifecycle — it runs for user rename statements/actions, while `alterTableCopy` publication (broad gate -> endpoint name pins -> source locking/revalidation -> private-replica replace) is untouched by the upstream hunks. Upstream's insertion anchor `reconcileAlterCopyAutoIncrement` is pre-existing `main` machinery from #26197, not part of this PR. `git range-diff` shows eleven commits patch-equivalent and commit 1 (`fix(alter): avoid global lineage gate during physical copy`) with only its import-hunk context shifted by upstream's import additions; no patch content changed.
- Exact-head revalidation, run over the full affected package set because upstream added tests inside the same packages this PR touches: `./pkg/sql/compile` - PASS 13.688s (includes both this PR's lifecycle/pool regression roots and upstream's new rename-admission roots); `./pkg/frontend` - PASS 34.112s (includes upstream's rewrite-rule/authenticate roots and this PR's whole-transaction rollback roots); the canonical race command `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` - PASS 18.887s, no failure in 100 runs; full `./pkg/tests/issues` - PASS 413.353s (includes upstream's new/updated issue_29133/issue_29095 roots and this PR's issue_29400/issue_277xx roots).
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `cb0ded487f` (`cb0ded487f49a9ad3113c654ccf1404949eec24a`)
Rebased onto current `main` `fd4767e488` after the behind event (head `16023e02d6` was reported behind; `main` advanced `51300cbd01` -> `fd4767e488`).
- The single new upstream commit `fd4767e488` (exclude fake primary key from LAST_INSERT_ID, #30004) touches `pkg/incrservice` and its test cases only, with no file overlap with this PR and no interaction with the ALTER COPY preparation/publication lifecycle; the rebase auto-merged and the prior role-filter reconciliation record above remains the current one.
- `git range-diff` confirms all twelve PR commits are patch-equivalent to the prior head `16023e02d691abaa1e46fc0481d40cc0509c1c2e`; only their base changed.
- Exact-head revalidation: `./pkg/sql/compile` - PASS 14.348s (includes both pool-boundary regression tests); the canonical race command `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` - PASS 8.890s, no failure in 100 runs; focused `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation` in `./pkg/tests/issues` - PASS 8.838s; the upstream-changed `./pkg/incrservice` package - PASS 5.350s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `a9d969890c` (`a9d969890c8a2e9076840237c163af588bce19fb`)
Rebased onto current `main` `a33dcfb2e5` after the behind event (head `cb0ded487f` was reported behind; `main` advanced `fd4767e488` -> `a33dcfb2e5`).
- The single new upstream commit `a33dcfb2e5` (perf: reduce wide-schema work and redundant gossip fixture startup, #30200) touches `pkg/sql/plan/{default_binder.go,build_show_util.go,types.go}` plus plan/logservice tests, with no file overlap with this PR and no interaction with the ALTER COPY preparation/publication lifecycle; the rebase auto-merged and the prior role-filter reconciliation record remains the current one.
- `git range-diff` confirms all twelve PR commits are patch-equivalent to the prior head `cb0ded487f49a9ad3113c654ccf1404949eec24a`; only their base changed.
- Exact-head revalidation: `./pkg/sql/compile` - PASS 21.080s (includes both pool-boundary regression tests and exercises upstream's plan-binder change through the normal compilation paths); the canonical race command `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` - PASS 7.788s, no failure in 100 runs; focused `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation` in `./pkg/tests/issues` - PASS 7.968s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `7f086296db` (`7f086296db9f32e3ebcd1d59ef36da325bd20fd9`)
Rebased onto current `main` `b1a6da4e16` after the behind event (head `a9d969890c` was reported behind; `main` advanced `a33dcfb2e5` -> `b1a6da4e16`).
- The single new upstream commit `b1a6da4e16` (fix(parser): reject overflowing type lengths and scales, #30176) touches `pkg/sql/parsers/dialect/mysql` plus tests, with no file overlap with this PR and no interaction with the ALTER COPY preparation/publication lifecycle; the rebase auto-merged and the prior role-filter reconciliation record remains the current one.
- `git range-diff` confirms all twelve PR commits are patch-equivalent to the prior head `a9d969890c8a2e9076840237c163af588bce19fb`; only their base changed.
- Exact-head revalidation: `./pkg/sql/compile` - PASS 13.528s (includes both pool-boundary regression tests); the canonical race command `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` - PASS 9.102s, no failure in 100 runs; focused `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation` in `./pkg/tests/issues` - PASS 9.154s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run. For the record, the prior head `a9d969890c`'s CI had already passed SCA Linux/arm64, UT Coverage on Ubuntu/x86, and the PROXY BVT compose before this rebase superseded it; its remaining checks were still queued/in progress and are replaced by the new run.
### Current exact head after review fix and rebase: `f0840a56e0` (`f0840a56e0d382b3219b449a69a84a53bc957dbe`)
Handles the shared P1 from aptend's thread and XuPeng-SH's mo-bot review (timestamp-only snapshot rewind after workspace-owned advancement), plus the behind event, in one cycle.
- Rebase: `main` advanced `b1a6da4e16` -> `bdbbd17792` (19 upstream commits: parser/plan/aggregate/function fixes, fileservice ENOSPC handling, race-UT runtime reduction, Sirius update; zero file overlap with this PR's delta). The rebase auto-merged; `git range-diff` confirms all twelve prior commits patch-equivalent.
- P1 fix (new commit `fix(alter): retain workspace-owned snapshot on copy return`): `alterTableCopy` no longer rewinds only the transaction timestamp after the pre-copy `databranchutils.AdvanceLineageSnapshot` workspace advancement. The rewind defer reintroduced by this PR's first commit was the exact defect main's #29539 removed; after `Workspace.AdvanceSnapshot` relocates transaction-local tombstones, a timestamp-only rewind leaves the workspace and snapshot in different generations and resurrects relocated deletes of earlier uncommitted DML. The workspace-owned advanced snapshot is now retained on every return path, matching the publication-side advance and the other owners; the duplicated `isTemp`/non-temporary advance branches collapsed into one mode-gated call. The design doc records the ownership rule and its #29539 lineage.
- New tests: `TestAlterCopyRetainsWorkspaceAdvancedSnapshotOnEveryReturn` (pessimistic-RC `Scope.AlterTableCopy`; any `SetSnapshotTS` rewind fails the test; retention asserted across the workspace-advance-failure and post-advance physical-copy-failure returns; mutation-verified in both directions) and `TestIssue29400CopyAlterKeepsRelocatedWorkspaceDeletesAfterReturn` (real cluster: uncommitted in-memory DELETEs survive a forced DN flush and the ALTER COPY return inside the same pessimistic-RC transaction and after commit).
- Exact-head validation: full `./pkg/sql/compile` - PASS 14.987s; the canonical race command `-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile` - PASS 7.286s, no failure in 100 runs; both new roots - PASS; full `./pkg/tests/issues` - PASS 329.117s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's green CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `ebda98e960` (`ebda98e960e398f4436338f6353f1064d5009161`)
Rebased onto current `main` `501c85ecdd` after the behind event (head `f0840a56e0` was reported behind; `main` advanced `bdbbd17792` -> `501c85ecdd`). No code change in this cycle.
- The single new upstream commit `501c85ecdd` (perf(test): shorten embed and isolated race process lifetimes, #30249) touches `Makefile`, `optools/run_ut.sh`, and `optools/ut_embedded_schedule_test.go` only — test-infrastructure files with zero overlap with this PR's delta; the rebase auto-merged.
- `git range-diff` confirms all thirteen PR commits patch-equivalent to the prior head `f0840a56e0d382b3219b449a69a84a53bc957dbe`; only their base changed.
- Exact-head validation: full `./pkg/sql/compile` - PASS 13.871s; the canonical race command (`-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile`) - PASS 6.486s, no failure in 100 runs; focused issue roots in `./pkg/tests/issues` (`TestIssue29400CopyAlterKeepsRelocatedWorkspaceDeletesAfterReturn`, `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation`, `TestIssue29400IndependentCopyAltersProgressInPessimisticRC`) - PASS 9.997s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `9c2e6a6257` (`9c2e6a62574f0b34881fb14a48561ebe4cd054dd`)
Rebased onto current `main` `f2093ae4b3` after the behind event (head `ebda98e960` was reported behind; `main` advanced `501c85ecdd` -> `f2093ae4b3`). No code change in this cycle.
- The two new upstream commits — `f2093ae4b3` (fix(json): reject wildcard and range paths in JSON_KEYS, #28328) and `bb2b725d0a` (fix(shardservice): preserve immutable read cache snapshots, #30187) — touch `pkg/common/moerr/error.go`, `pkg/container/bytejson`, `pkg/shardservice`, `pkg/sql/plan/function` JSON files, and BVT cases, with zero file overlap with this PR's delta. The rebase auto-merged.
- `git range-diff` confirms all thirteen PR commits patch-equivalent to the approved head `ebda98e960e398f4436338f6353f1064d5009161`; only their base changed, so the aptend implementation APPROVE (`PRR_kwDOFEPiGM8AAAABSZFhbw`) and the mo-bot approve (`PRR_kwDOFEPiGM8AAAABSZQRVg`), both recorded on `ebda98e960`, and the amended-design PASS (issuecomment-6186238709) review exactly this code.
- Exact-head validation: full `./pkg/sql/compile` - PASS 14.281s; the canonical race command (`-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile`) - PASS 9.351s, no failure in 100 runs; the upstream-adjacent `./pkg/common/moerr` - PASS 0.492s; focused issue roots in `./pkg/tests/issues` (`TestIssue29400CopyAlterKeepsRelocatedWorkspaceDeletesAfterReturn`, `TestIssue29400OrdinaryIndexedCreateRegistersTasksAfterCopyPreparation`, `TestIssue29400IndependentCopyAltersProgressInPessimisticRC`) - PASS 8.902s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's terminally green CI run (38688137369, CI Required SUCCESS) is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `ce9ed59493` (`ce9ed594933ffe3cf2ea8403b561956d1c833eac`)
Rebased onto current `main` `461bc8e349` after the behind event (head `9c2e6a6257` was reported behind; `main` advanced `f2093ae4b3` -> `461bc8e349`). No code change in this cycle.
- The two new upstream commits — `461bc8e349` (fix(plan): omit overwritten implicit fulltext ordering, #30189) and `b5a4d5c795` (fix(frontend): enforce Starlark OUT and INOUT parameter types, #30134) — touch `pkg/sql/plan` fulltext-index files, `pkg/frontend` Starlark files, and embed/config tests, with zero file overlap with this PR's delta. The rebase auto-merged.
- `git range-diff` confirms all thirteen PR commits patch-equivalent to the approved head `9c2e6a62574f0b34881fb14a48561ebe4cd054dd`; only their base changed, so the aptend implementation APPROVE (`PRR_kwDOFEPiGM8AAAABSZFhbw`), the mo-bot approve (`PRR_kwDOFEPiGM8AAAABSZQRVg`), and the amended-design PASS (issuecomment-6186238709) continue to review exactly this code.
- Exact-head validation: full `./pkg/sql/compile` - PASS 15.167s; the canonical race command (`-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile`) - PASS 7.856s, no failure in 100 runs; the upstream-modified `./pkg/frontend` (includes both this PR's whole-transaction rollback roots and upstream's new Starlark roots) - PASS 28.287s; focused issue roots in `./pkg/tests/issues` (relocated workspace-delete retention, ordinary indexed-CREATE registration, indexed independent pessimistic-RC publishers) - PASS 9.759s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The prior head's in-flight CI run is superseded by this push; the new head produces a fresh CI run.
### Current exact head after latest rebase: `a0e40253d0` (`a0e40253d0488e9c9f0b96752dec0724296df85d`)
Rebased onto current `main` `c46b893f61` after the behind event (head `ce9ed59493` was reported behind base `461bc8e349`, then conflicting while `main` advanced `461bc8e349` -> `83222fa837` -> `c46b893f61`). No PR-side behavior change in this cycle.
- The base hop through `83222fa837` picks up `8795f3699b` (revert: restore fulltext planner before #30189, #30285), upstream's fix for the CI blocker that failed the previous head's run `38703760162`: #30189's widened `tryApplyCoveredFulltext2` missed the stale call site at `apply_indices_fulltext_snapshot_test.go:180-182` and broke the `pkg/sql/plan` test build, failing SCA Linux/arm64, UT Coverage Ubuntu/x86, and UT Test Ubuntu/x86, blocking the Coverage merge at its `Verify coverage prerequisites` step, and turning the `CI Required` gatekeeper red — one verified root cause, pre-existing on `main`, with this PR contributing zero lines to `pkg/sql/plan`. The current base additionally contains the properly re-landed fulltext work `e8b3ed7f21` (fix(plan): integrate fulltext ordering and covered score limits, #30289); `mo-cgo-test -run '^$' ./pkg/sql/plan` passes on this head, so the defect is gone from the merge result.
- The rebase required a semantic interleave in two hunks where upstream `b6789851ca` (#30222) added the statement-retry `lastInsertIDBaseline` to the exact `Compile` flag block this PR extends: `types.go` now declares both upstream's `lastInsertIDBaseline uint64` (with its retry-restore comment) and this PR's `skipIndexTaskRegistration bool`, and `clear()` resets both (`c.lastInsertIDBaseline = 0` upstream; `c.skipIndexTaskRegistration = false` this PR, beside the other per-statement flags). Upstream's compile2.go save/restore pair is untouched and this PR's pool boundary is unchanged. Upstream `a85d90efc9` (#30334) also added cross-CN `SYNCCOMMIT` fences to its own `TestIssue29400CopyAlterRetainedGatePromotionFastFails` root inside `pkg/tests/issues/issue_29400_test.go`; the merged file keeps those fences and this PR's roots. The whitespace part of the resolution was folded into commit 10, preserving the clean 13-commit stack.
- `git range-diff` shows eleven PR commits patch-equivalent; commits 10 and 11 differ only by the interleaved upstream field/reset inside their existing hunks — every line the PR itself adds is unchanged, so the aptend implementation APPROVE (`PRR_kwDOFEPiGM8AAAABSZFhbw`), the mo-bot approve (`PRR_kwDOFEPiGM8AAAABSZQRVg`), the design-first PASS (issuecomment-6141109182), and the amended-design PASS (issuecomment-6186238709) continue to review exactly this code.
- Exact-head validation: full `./pkg/sql/compile` - PASS 34.197s (includes this PR's lifecycle/pool roots and upstream's new retry-baseline and calendar-interval roots); full `./pkg/frontend` - PASS 21.086s (includes upstream's show-metadata/authenticate changes and this PR's whole-transaction rollback roots); `./pkg/sql/plan` build check - ok 1.443s; the canonical race command (`-race -tags matrixone_test -count=100 -timeout=120s -run '^TestCompilePoolHandoffClearsPrivateIndexRegistrationPolicy$' ./pkg/sql/compile`) - PASS 4.120s, no failure in 100 runs; focused roots in `./pkg/tests/issues` (relocated workspace-delete retention, ordinary indexed-CREATE registration, indexed independent pessimistic-RC publishers, plus upstream's re-fenced retained-gate root in the shared file) - PASS 11.945s.
- `gofmt -l`, `git diff --check`, the protected-scope check, and the clean-tree check passed on the exact head. The previous head's red run `38703760162` (verified upstream-caused) is superseded; this push produces a fresh CI run for the new head.
### Current exact head after latest rebase: `2f4f928170` (`2f4f928170cb614dd8570ff6f4151f98dc1d4821`)
Rebased onto current `main` `76deafc806` after the behind event (head `a0e40253d0` was reported behind; `main` advanced `c46b893f61` -> `76deafc806`). No code change in this cycle.
- The single new upstream commit `76deafc806` (fix: report SELECT division-by-zero warnings, #30314) touches `pkg/sql/compile` expression/remoterun protocol files plus new division-warning test roots, `pkg/sql/plan/function/arithmetic.go` plus new plan test roots, rege…
…ck (#30580) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #29710. Backports #29754 (`aee2a0b3764781a8ca908618548dfef75e336263`) to `4.2-dev`. ## What this PR does / why we need it: A later statement rollback could rewind transfer progress past replacements retained from a successful statement. Replaying that interval duplicates persisted tombstone replacements; another merge then fails the strict transfer cardinality check (`expect 20, got 10`). Conversely, rolling back the transferring statement must retain recovery debt so immediate COMMIT cannot skip transfer. - Save the existing workspace transfer frontier and pending debt alongside each statement's write offset; restore both on rollback without rewinding the operator snapshot. - Include intermediate merged objects when recovering in-memory RowIDs, which earlier transfers update in place. Preserve the default snapshot and persisted-source projections. - Prepare targets and prefetch only after finding a matching workspace delete. - Retain `4.2-dev`'s `ApplyFlush` tracing, lookup path, batching, and strict cardinality guard. No format, configuration, or native changes. This is an independent backport. The lineage snapshot caller correction in #30576/#29539 remains separate. Validation (Go 1.26.4, Darwin arm64, CPU CGo): - Full `disttae` and `logtailreplay` packages pass normally and with race. - All seven snapshot-harness consumer tests pass normally and with race: memory/persisted/mixed × three rollback boundaries across real TN flush and a second merge; immediate COMMIT; partial persisted I/O failure and cancellation after memory transfer; durable fresh-transaction assertions. - Prefetch admission checks no-demand lookup/prefetch avoidance, ten distinct demanded prefetch completions, unchanged RowID on metadata failure, and scratch cleanup. - Counterexample: reverting only the intermediate-memory-source projection makes the new real-engine transferring-statement rollback test fail with ten surviving rows; the candidate passes. The persisted `expect 20, got 10` baseline witness was established separately before this backport. - External MySQL probe against the candidate embedded cluster passes retained DELETE + later statement error + continuation/COMMIT, error + immediate COMMIT, and full rollback with fresh-connection results. This checks public rollback behavior, not deterministic public SQL reproduction of the forced merge interval. - Separate bounded race repetitions pass: admission 100, statement rollback 4, rollback across merge 3, partial I/O recovery 15. Counts use a 30-second per-test budget and measured one-run race durations. - `go vet`, configured molint, configured golangci-lint against the exact branch base, formatting, and diff integrity pass. Reproduce the repository regression checks: ```sh .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/vm/engine/disttae ./pkg/vm/engine/disttae/logtailreplay .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s -run '^(Test_RCSnapshotAdvancePreservesUncommittedDeletes|Test_RCSnapshotAdvanceHarness(Rollback|Commit|SubsequentStatement|StatementRollback)|TestRCSnapshotRollbackAcrossMerge|TestTransferPartialIORecovery)$' ./pkg/vm/engine/test ``` Both selections also pass with `-race -count=1 -timeout=600s`. No workload throughput or physical I/O improvement is claimed.
Backport the applicable workspace-owned lineage snapshot protocol from 7b3d0c3 (matrixorigin#29539), and remove ALTER's timestamp-only rewind. Cover the real catalog DROP/rename consumer and both tombstone modes, including statement rollback followed by immediate COMMIT. Fixes matrixorigin#30541.
…30576) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #30541. Backports the applicable correction from #29539 (main commit `7b3d0c3bcfa`); related to #29540. ## What this PR does / why we need it: Repeated COPY ALTER in an RC transaction can leave a catalog DELETE pointing at a row's old Rowid after TN flush/merge relocates it. The lineage refresh previously updated only the transaction operator's snapshot, exposing both the relocated committed row and the transaction's replacement. The next internal DROP then panics on the `mo_tables` singleton-result guard. Use the existing `Workspace.AdvanceSnapshot` owner through one shared physical-lineage timestamp helper, covering COPY ALTER, internal PITR, and frontend CLONE/SNAPSHOT callers. Remove ALTER's timestamp-only rewind: once tombstones transfer, restoring just the timestamp cannot restore the paired workspace state. Preserve the physical history boundary (`updated physical - 1ns`), tenant-less frontend behavior and publication locks. This branch has no TRUNCATE lineage refresh to backport. Reuse the existing forced-flush harness for both in-memory and persisted tombstones, checking exact replacement keys, repeated refresh, commit/full rollback, and statement rollback followed by immediate COMMIT. Add a real catalog DROP/rename/flush regression that checks the replacement table ID and successfully executes the next `db.Delete`, with no production test hook or relaxed catalog guard. An isolated operator-only mutation deterministically reproduces two catalog rows and the original `delete table failed: query failed` panic. Validation before rebase, at original head `162473f0a8b`, Go 1.26.4 / Darwin arm64 CPU with branch-built native libraries: - Full `pkg/frontend/databranchutils`, `pkg/sql/compile` and `pkg/frontend` UTs pass normally and with `-race -count=1`. - All seven tests in the affected engine snapshot-advance/catalog fixture closure pass normally and with `-race -count=1`; bounded exact-test race repetitions cover fixture reset/reuse. - Real MySQL TCP probe on the existing embedded cluster passes prior workspace INSERT/UPDATE, repeated transactional ALTER, COMMIT/ROLLBACK, historical reads, CLONE/PITR, exact catalog cardinality and teardown. Existing historical-lineage BVT coverage is retained unchanged; the public probe does not claim a deterministic mid-ALTER flush. - Incremental configured golangci-lint: zero issues. `go vet` and MatrixOne analyzer complete; the analyzer reports no diagnostics in changed files. Formatting and `git diff --check` pass. - Independent solution/design and final overall review: `gpt-6.1-sol`, reasoning `xhigh`. The helper adds constant delegation work and reuses the required existing tombstone-transfer work at lineage boundaries, proportional to workspace deletes and relocated objects. No storage/wire format changes. No scale benchmark or partial-transfer I/O fault-injection claim. CI is pending. ### Rebase update Rebased onto `fe9c5ea3964` (`4.2-dev`, including #30580). New head: `f7523448ec8`. The shared snapshot test fixture conflict was resolved by retaining all seven upstream test bodies (including mixed tombstones, immediate COMMIT, repeated rollback/merge, and partial-I/O recovery) and this PR's lineage helper/replacement-key assertions. Immediate-COMMIT cases already supplied by #30580 were not duplicated. The seven other PR files are identical to the original head. Formatting, diff integrity and range-diff/content preservation checks pass. No test commands were rerun for this rebase; the local execution results above describe the original head. Fresh CI must validate the combined revision.
…nce (#30602) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #30541. Production fixes are already present on main through #29539 and #29754; the release-branch correction is #30576. ## What this PR does / why we need it: Add the missing deterministic catalog regression for COPY ALTER's DROP/rename window. Existing main tests cover transferred data deletes and replacement keys, but do not check the same-name catalog replacement and the next real `txnDatabase.Delete` singleton guard. The test commits an original table, creates its transaction-local replacement, drops and renames through the real engine APIs, synchronously flushes `mo_catalog.mo_tables` on TN, and advances through the shared lineage helper. It then requires exactly the replacement table ID and successfully executes the next real Delete. There is no statement boundary between flush and verification: a normal boundary could repair the stale tombstone and hide the original defect. Setup reuses EnginePack with long checkpoint scanning, one PK column, two table identities, and no user data rows. Pack, setup/RC transactions and query results register cleanup immediately. No production hook, state, guard relaxation or runtime change is introduced. Validation on Go 1.27.1 / Darwin arm64 CPU, with matching native provenance: - New focused regression passes normally and with race; the normal test body takes about 0.75 s. - Full `./pkg/vm/engine/test` passes normally (162.995 s) and with race (226.079 s): 167 top-level passes in each mode; two existing tests remain skipped and are not claimed as executed. - An external Go overlay changes only the shared helper back to raw operator advancement. Its witness confirms both original and replacement IDs, then catches the real `delete table failed: query failed` panic from `db.Delete`. The mutation is not delivered. - The exact new test also passes 37 repetitions under race in one process (31.277 s total); count selected from a 30-second budget and a measured 0.79 s single-test race duration. - After main advanced to `d0e7f9a552f`, the exact regression also passes normally and with race using an external overlay of the complete upstream delta. Full-package results above apply to the frozen `8732827` base; the overlay check is focused compatibility evidence. - `go vet`, repository-pinned molint and configured incremental golangci-lint against `873282742714436bff407dfcdbbe879147162bd3` pass; formatting and diff integrity pass. Commands: ```sh .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=900s ./pkg/vm/engine/test .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=1200s ./pkg/vm/engine/test ``` This is regression coverage for the existing main fix, not a new production fix. It does not claim deterministic public SQL scheduling of a mid-ALTER flush, execution of the original Matrixflow upgrade workload, crash recovery, or a workload performance improvement. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29540 (#29540).
Found while investigating the Ubuntu UT failure in #29535 (job log). This is a transaction/lineage correction independent of that PR's IVF changes.
What this PR does / why we need it:
A no-op lifecycle UPDATE still deletes the old Rowid and inserts a replacement. After TN flush/merge relocates the committed row, advancing only
TxnOperator's snapshot can expose the relocated row alongside the transaction's own replacement. The failing PICK transaction first affected one SNAPSHOT registry row, then affected two after a registry flush, and subsequently failed the uniqueness guard.Workspace.AdvanceSnapshot, the existing owner of RC tombstone relocation, through one stateless lineage timestamp helper. Cover COPY ALTER, TRUNCATE, internal PITR, CLONE and snapshot creation; replace the duplicated frontend/compiler timestamp protocol.updated physical − 1ns), frontend tenant-less behavior and the publication write barrier required by commit validation. Keep the one-row registry guard.Validation
Local Linux amd64 / Go 1.26.4, native artifact source generation verified:
pkg/frontend,pkg/sql/compile,pkg/frontend/databranchutilspass-race.TestDataBranchPickpasses-race, includingaccept_mixed_update_and_insert; replacement regression passes 17 repetitions under-race. Existing engine tests pass adaptive exact-test race stress; expanded immediate-COMMIT rollback matrix also passes.-race: prior update/insert across repeated transactional ALTER, commit/rollback, historical snapshot reads, PITR creation, branch TRUNCATE and exactly one SNAPSHOT registry row. Existing historical-lineage BVT covers these scenarios; no duplicate cluster fixture added.git diff --checkpasses.gpt-6).Cost and limits
Production code net −5 lines; tests net +134; documentation unchanged. Required tombstone-transfer work runs at lineage snapshot advancement, proportional to existing workspace deletes/object changes. No scale benchmark was run. The engine witness deterministically covers visibility; actual SQL PICK supplies commit evidence, without a forced mid-PICK flush. Partial transfer I/O failure injection was not exercised separately. CI is pending.