Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
One blocking schema-evolution regression found. Focused frontend tests could not run because the worktree lacks cgo/libmo.dylib.
P1 - Allow target-only historical type changes or reject them consistently (pkg/frontend/data_branch_hashdiff.go:2625)
checkSchemaCompatibility accepts a target-only column regardless of its type, so t0(a,b) and branch t1(a,b,c varchar) are compatible. However, after t1 first adds c int and then modifies it to varchar, every DIFF/MERGE walks the old physical generation and this mapping rejects old c int against endpoint c varchar before even opening CollectChanges. The column is target-only and is deliberately omitted from MERGE apply (commonVisibleIdxes), so its historical representation cannot affect t0; nevertheless all operations fail, including when there were no writes to c. Skip/project such non-common historical columns as NULL, or make the endpoint compatibility check reject this evolution up front. Add an end-to-end regression covering add-target-only-column -> modify its type -> DIFF/MERGE.
|
Addressed the blocking historical-generation schema mapping regression. Changes:
Coverage:
Validation:
The BVT fixtures were not executed locally because this worktree has no mo-tester runner; the new-head CI will validate them. |
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed updated head c515a14. The target-only historical type-drift blocker is closed: incompatible non-common columns are projected as NULL and hydrated from the endpoint, while common-column and primary-key drift remain rejected. DIFF and MERGE regressions cover both unchanged and updated rows. No remaining blockers found.
# Conflicts: # pkg/frontend/data_branch_snapshot_test.go
fengttt
left a comment
There was a problem hiding this comment.
Please cleanup test cases, with better names.
Actually there need to be a solid/clean doc on the behavior of the merge. I am not sure are all the cases listed/handled in reasonable way, and I want to read that doc and review the design. This is a pretty tricky thing. We should do the safe route -- unless we are exactly sure what to do, raise an error. The "we are exactly sure what to do" part should be designed/documented/reviewed.
aptend
left a comment
There was a problem hiding this comment.
Requesting changes for one P1 concurrency-correctness issue.
[P1] Serialize historical-owner publication with copy ALTER
The historical snapshot/PITR probes in pkg/sql/compile/alter.go use SELECT ... FOR UPDATE, which only protects owner rows that already exist. A concurrent publisher can choose its snapshot timestamp or PITR create time before copy ALTER commits, while its catalog row is not visible yet. ALTER then observes no historical owner, skips lineage preservation, performs the copy-and-swap, and the owner commits afterward with a time before the ALTER boundary.
A later data branch created from that historical owner can therefore resolve the old physical generation without an ALTER edge to the current generation, so DIFF/MERGE cannot reliably reconcile schema identity across the copy ALTER.
The new PITR mo_branch_metadata lock only serializes PITR publication with compaction: ALTER does not acquire that lock before its early owner probe, and CREATE SNAPSHOT does not acquire it at all. Please add a stable serialization point shared by CREATE SNAPSHOT, CREATE PITR, and copy ALTER before timestamp selection/owner probing, or revalidate the owner set under such a lock before the swap. Please also add a barrier-based concurrent regression test for this interleaving.
Current head also has a failing PROXY BVT: pitr_basic.sql times out while selecting mo_pitr. That should be investigated or rerun before merge.
# Conflicts: # pkg/frontend/data_branch_hashdiff.go # pkg/frontend/data_branch_hashdiff_test.go # pkg/sql/plan/function/func_unary_test.go
# Conflicts: # pkg/frontend/data_branch.go # pkg/frontend/feature_limit.go # pkg/frontend/feature_limit_test.go # pkg/sql/compile/alter.go # test/distributed/cases/snapshot/sys_create_snapshot_for_sys_db_table_level.result
# Conflicts: # pkg/frontend/clone.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head c955ed6. One P1 correctness race remains.
doCreateSnapshot chooses the snapshot timestamp before publishing the owner row, and does not acquire a stable lock shared with COPY ALTER. prepareAlterDataBranchLineage probes owner rows with SELECT ... FOR UPDATE, but an empty result does not serialize against a concurrent later insert. The same issue exists for PITR because ALTER does not take the PITR-side stable lock before its early owner probe.
Interleaving: snapshot/PITR chooses time t; COPY ALTER sees no owner and skips the A-to-C lineage handoff, then swaps A to C; the owner row commits with timestamp t. A later data branch resolves old A at t, while current C has no LCA lineage, leaving the branch histories disconnected.
Please introduce synchronization on a stable key shared by owner publication and COPY ALTER before timestamp selection/owner probing, and add a deterministic barrier test covering this interleaving.
# Conflicts: # pkg/sql/compile/alter.go
|
Fixed the empty-owner publication race in 7755749. CREATE SNAPSHOT, CREATE PITR, and COPY ALTER now cross the same bootstrap-created mo_feature_registry write barrier before timestamp selection/owner probing. The write preserves the registry metadata, serializes pessimistic transactions by row lock and optimistic transactions by write conflict, and snapshot/PITR commit conflicts are now returned instead of being reported as success. I initially used mo_database as the stable key, but an authenticated cluster regression exposed that as invalid because it enters special catalog DDL tuple parsing. I replaced it before pushing; both issue cluster tests now pass, along with the full frontend/databranchutils/compile normal and race suites and pkg/vm/engine/test. Please re-review the current head. |
aptend
left a comment
There was a problem hiding this comment.
Requesting changes for one remaining P1 correctness gap.
[P1] Serialize the engine/internal PITR publication path with COPY ALTER
The new stable publication barrier closes the frontend doCreatePitr path, but CREATE PITR ... INTERNAL is deliberately routed to engine execution (CreatePitr.StmtKind returns defaultStatusTyp) and reaches Scope.CreatePitr in pkg/sql/compile/ddl.go. That path resolves and stores the target object ID during planning, then selects now and inserts into mo_pitr without crossing LineageOwnerPublicationLockSQL.
Concrete interleaving: an INTERNAL PITR resolves old generation A; concurrent COPY ALTER crosses the barrier, observes no published historical owner, skips lineage preservation, and swaps A to C; the PITR then inserts its old timestamp/object ID. A later data branch restored from that PITR can resolve A with no lineage edge to current C, reproducing the disconnected-generation failure this barrier is intended to prevent. INTERNAL PITR is a real supported path and is exercised by pkg/tests/ddl/ddl_test.go.
Please make the INTERNAL/engine path share the barrier across object resolution, timestamp selection, and publication. Adding the write only immediately before the insert is insufficient if the plan already captured a stale object ID; either route this path through the frontend creation flow or refresh/re-resolve the object under the barrier. Add a deterministic regression for CREATE PITR ... INTERNAL racing COPY ALTER.
|
Addressed the INTERNAL PITR publication race in db2107d.
I added a deterministic COPY ALTER interleaving and a stale planned-ID regression. I also fixed the current PESSIMISTIC BVT failure: Validation:
|
|
Synced with current |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review complete on exact head dba14dfe0c. The prior historical-owner/COPY ALTER race is closed by a real stable-row write barrier shared by frontend snapshot/PITR publication, INTERNAL PITR publication, and COPY ALTER. The INTERNAL path now refreshes its RC snapshot and re-resolves the database/table object ID under that barrier instead of using the generation captured during planning. I traced all production owner-write entry points, the optimistic WW-conflict and pessimistic lock paths, transaction cleanup, lineage preservation, and the latest merge resolutions; no remaining blocker found. Six focused race regressions passed 100 iterations each, full race suites for frontend/databranchutils, frontend, and sql/compile passed, all eight owning packages passed test/build/vet, and embedded-cluster TestPitrCases passed. Required CI is green and this exact head merges cleanly with current main.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24549
What this PR does / why we need it:
This PR continues the unfinished work from #24666 while preserving its original commits and authorship.
It supports schema evolution in DATA BRANCH DIFF/MERGE by matching columns with stable identity, separating physical and visible common-column indexes, projecting compatible historical batches, comparing common columns, preserving target-only data, and maintaining ALTER lineage ownership.
Safety contract
DIFF/MERGE is allowed only when the endpoint schemas can be mapped without guessing:
Historical batches are projected through the lineage-resolved layout. A target-only column whose historical representation changed is omitted from the old batch and reconstructed from the current endpoint instead of being cast or matched by name.
COPY ALTER preserves the replaced physical generation only while a live data branch or a covering snapshot/PITR owns it. Snapshot/PITR publication and COPY ALTER update the same bootstrap-created
mo_feature_registryrow before choosing/probing the history boundary, while explicitly preserving the row's metadata: pessimistic transactions serialize on the row lock, while optimistic transactions serialize through write-write conflict and whole-statement retry. Snapshot/PITR creation now returns commit conflicts instead of reporting false success. After a wait, ALTER probes owners in a fresh transaction so it does not reuse an old SI snapshot. If identity, ownership, or generation connectivity cannot be proven, the operation returns an error.Both PITR execution locations follow this contract. The frontend path and
CREATE PITR ... INTERNALengine path cross the same stable barrier; the INTERNAL path refreshes a pessimistic-RC snapshot after waiting and re-resolves the current database/table ID before selecting its timestamp and publishingmo_pitr, rather than reusing the ID captured during planning.Review fixes on the latest head:
Seqnum, while preserving pureFIRST/AFTERreorderings;Validation
go test ./pkg/frontend/databranchutils ./pkg/frontend ./pkg/sql/compile ./pkg/vm/engine/test -count=1go test -raceforpkg/frontend/databranchutils,pkg/frontend, andpkg/sql/compile, plus focused repeated race tests for lineage-owner publicationTestPreparePitrPublicationSerializesCopyAlterandTestResolveCurrentPitrObjectIDRefreshesPlannedTableID, each with-race -count=100, plus productionTestPitrCasesTestIssue26087ConcurrentDataBranchQuotaandTestIssue26114CrossAccountBranchUsesTargetQuotaAndOwnershipgit diff upstream/main --checkmo-pr-preflight-reviewandmo-self-reviewThe BVT fixtures are included for DIFF/MERGE identity redefinition and table/account/database historical-owner cleanup; they are executed by CI because this local worktree has no standalone
mo-testerrunner.