Skip to content

fix(compile): preserve canonical COPY ALTER publication and rollback - #28418

Closed
VioletQwQ-0 wants to merge 21 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28319-copy-alter-publication
Closed

VioletQwQ-0 wants to merge 21 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28319-copy-alter-publication

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG
  • Improvement
  • Documentation

Which issue(s) this PR fixes:

Related to #28319. Draft: the concurrency/performance issue is not accepted as fixed. QA required: yes.

What this PR does / why we need it:

Current phase: revision-4 design decision (2026-10-15)

Published design-only head: 56a4c48def089624f2dc1572ec8ea616399db843. Executable production/test/runner files are unchanged from f7903a01aa528bb05b5662d6b2bdd859cf4212f5. Inspected main: 8795f3699b40504376343fa1acda8b4619f0c76e. Current conflicts are not resolved by this documentation commit.

The revision-4 protocol supersedes the old late-exclusive-publication proposal. It proposes a narrow ordinary ADD/DROP PRIMARY KEY fast path using main's scalar replacement admission: shared C/G/D plus exclusive source K/T held through the transaction. Copying avoids global exclusive admission. Complex/unsupported tables and enabled persistent View refresh remain broad. Any fresh broad retry is bounded to one and must occur before copying; ordinary contention does not recopy. No SQL, catalog, wire or user setting is added.

Maintainer approval is PENDING. The decision record identifies the explicit protocol/barrier/fallback questions for @cpegeric and @LeftHandCold. Production repair, main conflict integration and new-head remote acceptance follow that decision. No implementation re-review is requested yet.

Validation of this update: four Markdown documents only; local links, fenced blocks, pinned replay identities and git diff --check pass. No executable change and no new runtime/race/BVT result is claimed. The complete PR retains canonical test/distributed/cases/ddl/alter_copy_publication.sql and .result; its historical correctness evidence does not prove this new fast path.

The current assertion matrix and runner preparation contract require deterministic path/concurrency and failure proof, full paired 1/2/4/8-worker measurements, <=45.55s per changed top-level race test in Ubuntu CI, three serial equivalent fixed reconstructed nightly runs with the original topology/error contract, and deployment QA. All repaired-head runtime gates remain NOT_RUN/PENDING. Revision 3's reduced 1/2-worker acceptance proposal is withdrawn.

The already successful personal Ubuntu run c105-20261015T081332Z-a9617d compared old base 8a4c84f4516d5098de9eef50b8afecc7524f37a2 with old head 5be67e3694712bc208e42c8db4c6032a2d896f65. It establishes a reusable runner lifecycle, not performance of the current PR. The new generation needs Go 1.27.1, rebuilt native artifacts and shared/exclusive-mode observations. Accepted nightly reconstruction does not imply current image/topology/admission or runtime acceptance.

Remaining review comments: the three design/acceptance threads (aptend r4001780128; XuPeng-SH r4008474122 and r4009643127) still need traceable maintainer approval and required acceptance. The two XuPeng-SH race threads (r4008474132 and r4009643130) still need actual per-test Ubuntu/CI timings on the repaired head. Each remains open independently; no review is represented as resolved.

Historical f790 maintenance and validation record — superseded status/plan wording

The following is retained for provenance. Its revision-3 proposals, old current-main/status wording and unsent-comment status are historical. The revision-4 section above is authoritative for the current phase; the design decision request is being published separately.

This maintenance normally merges actual main fcad62a8ff06000e682824802f1155cbeea02a2f into the previously published 0f24cded0f6f85d3f8c5b9ef09943675143896cd, preserving both histories. The main COPY changes preserve live source definition/version validation, wide-column replay context and source FK identity; CREATE VIEW lifecycle admission also comes from main. The sole merge conflict was a compiler test executor: resolution retains both the PR's statement-option observation and main's CREATE context/error tracking. The earlier types.go formatting correction remains intact.

Actual merged dependency #30111, commit f14a1fa9ee813529b7bde89ecc74dddca420dc00, is in the main ancestry. The earlier main integrations 175a645a85994f2c95992d3aa8d6dacb6d9e167f and 5c959556431225711a33d1af5fe9a5b6d4060122 are retained. This update does not inherit the closed/unmerged #30110 alternative or require an unmerged EXPLAIN fix.

Fresh review found a shared embedded-test fixture defect: RunActive borrowed an initialized cluster while bypassing Run's exclusive callback admission and failure quarantine. Both now use the same owner. A borrow never initializes an inactive generation, waits for an independent callback, rejects nested/closed/sealed use, and registers generation-bound failure cleanup. Callback failure, panic and late test failure seal/retire the fixture; stale cleanup cannot close a replacement. Three new regressions fail on the prior source and pass after repair; the mutual-exclusion regression waits for the second entry before its negative observation. This is test-fixture lifecycle repair, not a COPY publication protocol redesign.

The full PR retains canonical C/G/D admission before source locks, retained-owner FastFail, source identity/re-resolution, atomic replacement, allocator/FK maintenance and synchronous index/task publication. Admission already retains the broad snapshot lock when delayed-publication eligibility is evaluated, so ordinary pessimistic RC COPY rejects the split and uses the existing fallback through transaction completion. The shortened publication critical section, concurrent independent-table preparation and performance benefit are not delivered. Existing peer tests run sequentially and fallback tests do not establish split preparation or split retry/reuse. The NewPluginIndexes preparation/publication-set consistency identified during review must also be reconciled before activating that currently unreachable split path. Revision3 is still a proposed design requiring a maintainer decision; this maintenance neither removes the canonical lock nor infers approval.

Current candidate f7903a01aa528bb05b5662d6b2bdd859cf4212f5, tree 03d87ac5f2718a59769d51eefab00cc26cc5fcca, is validated against merged main fcad62a8ff06000e682824802f1155cbeea02a2f. The latest observed main 5d971d07a7c5a52a71f2c10390b109cebf5c0825, #29994, is not merged or represented as tested here. Its six changed paths do not intersect this PR's final 42 paths. Independent review traced its production changes to indexed CASCADE DELETE/self-REPLACE; the selected COPY execution paths do not trigger them. Its additional self-FK COPY BVT is adjacent coverage not included in these results. The frozen maintenance validation remains applicable without claiming the later fixes.

Validation uses Darwin arm64, Go1.27.1, CGo enabled, GOEXPERIMENT=simd, MO_CL_SIMSIMD=0:

  • Current full-diff Go files are gofmt clean; git diff --check and configured incremental golangci-lint over the affected package directories pass.
  • Integrated focused admission/retry/replay/create-view controls: 67 RUN, 20 top-level PASS on clean ab32. The only later source changes are the embedded fixture owner/tests. Compiler owning package: 3137 RUN, 1447 top-level PASS on 21cb; its only successor change is a test-entry synchronization in the embedded package. These bindings are preserved rather than relabeled as reruns on f790.
  • Borrowed-fixture regressions first fail 3/3 on the prior implementation. The final shared-fixture selection passes 34 RUN/23 top-level tests; its tested dirty delta exactly maps to f790. Actual public ^TestIssue28319 on f790 passes 36 RUN/24 top-level tests, and retained-gate FastFail passes 18 RUN/1 top-level test. Current combined -race selection passes 70 RUN/47 top-level tests with no race reports, covering both the shared fixture and public COPY tests. These local results do not satisfy the requested Ubuntu timing gate.
  • Formal make build-with-prebuilt-native passes on f790. Actual service SHA256: dd8553a168eab3d5d96221cb577a253ace45e83a07450ac0f930ed48940d16fb. Native provenance is verified; execution observes the owned libmo loader path and matching native hash. Earlier service binaries are not represented as this build.
  • Unchanged canonical test/distributed/cases/ddl/alter_copy_publication.sql and .result pass 31/31 twice on that service, zero failed/ignored/abnormal statements. Formal ISCP startup is observed. Database and global snapshot absence are checked before repetition and after execution; all owned service and tester process groups are absent, cleanup COMPLETE. This exercises existing COPY syntax, ADD/DROP PRIMARY KEY, historical rows, views, allocator/FK preservation and rollback without golden regeneration.
  • Historical gossip allocator/socket/fixture evidence remains 65 RUN/14 top-level PASS on the prior frozen head; pkg/logservice bytes are unchanged. It is reused only for that fixture scope. Earlier broad package totals, binaries and performance-driver results remain historical and are not promoted to current-head whole-package results.

Original failures remain recorded. The first current public invocation failed before SQL assertions because Darwin rejected the long Unix-socket path; an actual long/short socket control justified the new owned short TMPDIR, followed by the current PASS. The first canonical run completed both31/31 but its wrapper exited during a transient post-termination process-group permission check; independent process inventory and ESRCH observations established recovered cleanup. That initial wrapper remains FAIL. The corrected bounded cleanup wrapper was independently frozen/reviewed and the subsequent R2 execution supplies the final runtime PASS. Testers own separate process groups; timeout and final cleanup cannot silently omit Java descendants.

Fresh result-blind Astra Stage A inspected the complete initial production/test diff and raw issue contract, excluding author design/review narratives until Stage B. It independently identified the unchanged original acceptance gaps and the borrowed-fixture defect. The same reviewer then checked the actual repair, red/green mappings, current execution, original comments/threads and latest-main delta. The final change map contains 42 paths. Author self-review is separate. The review supports scoped maintenance publication while the original full-function gates remain unmet; this is not a Ready declaration.

QA required: yes. Local correctness and cleanup do not establish the original workload, deployed lifecycle/cache behavior or design acceptance.

Remaining requirements: named maintainer decision on the exact revision3 protocol reconciled with actual main admission; original nightly runner/tool/data/timeout identity; paired baseline/head ADD/DROP at 1/2/4/8 workers with observed copy counts, throughput/P95 and <=10% single-worker median regression; three equivalent original-nightly runs without unexpected timeout/connection failure; current Ubuntu <=45.55s per-test race-budget evidence; full QA and reviewer acceptance. Candidate-only diagnostic workloads and Darwin timings do not substitute for these contracts. The same versioned acceptance matrix is retained.

The latest review refresh still contains 12 formal reviews and five unresolved threads, with no revision3 approval found. Existing syntax and canonical correctness tests do not close the missing optimization/performance contract. Responses are prepared UNSENT; no comments, resolutions, re-review requests, remote experiments or CI reruns were sent. This PR remains Draft.

@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Sep 8, 2026
@mergify mergify Bot added kind/bug Something isn't working kind/enhancement kind/test-ci labels Sep 8, 2026
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review September 9, 2026 02:35

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPT-6 medium deep review at exact head b3b000b.\n\nP1 — mandatory design approval remains unresolved. docs/design/20260911-copy-alter-publication-review.md:18 explicitly states that the conditional handoff is not maintainer approval, and the requirement remains open. The change affects snapshot boundaries, transaction retry generations, and deferred index lifecycle ownership across frontend/compiler/plugins; the mandatory design gate therefore cannot pass.\n\nP1 — required workload/performance acceptance evidence remains open. docs/design/20260911-copy-alter-publication.md:237 requires the original nightly workload and paired baseline/head measurements at 1/2/4/8 workers, with throughput, latency, regression, and timeout criteria. These measurements are still absent despite green ordinary CI.\n\nPlease obtain traceable approval of the exact design revision and attach the required workload/performance evidence.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@fengttt You were right to call out the re-review request. My earlier “Addressed the CR” update mixed your questions with conflict and validation details, then requested review again five seconds later. That was premature. Here is the direct answer.

What COPY ALTER means here

It is the existing ALTER TABLE ... ALGORITHM=COPY execution path: build a replacement table, copy the source data and rebuild the required indexes, then publish the replacement. This PR adds no SQL command, syntax, or public function.

The problem in #28319 is that expensive preparation holds the shared lifecycle/publication protection and serializes ALTERs on otherwise independent tables. The proposed change moves copying and synchronous index preparation outside the global publication critical section for eligible automatic-commit pessimistic-RC operations, while retaining source protection and revalidation before publication. Explicit transactions and other unsupported modes retain the existing path.

Which SQL and assertions exercise it

At current head b3b000be5f1c41555b06356481fbe66d9fb041c8, the BVT explicitly executes:

alter table t algorithm=copy, add primary key(id);
alter table t algorithm=copy, drop primary key;

It checks rows returned through the existing view, subsequent AUTO_INCREMENT insertion, historical snapshot reads, rollback, primary-key metadata, and foreign-key metadata. These are SQL correctness checks, not proof of the concurrency/performance benefit.

The separate embedded SQL regressions cover independent-table progress, same-table serialization, and publication waits that reuse preparation rather than copying again.

What has actually run, and what remains open

  • The per-script report for the earlier head dcaa9216a9329869aefd747aebbe7c329222f1a0 records alter_copy_publication.sql as 31/31 passed, with no ignored or abnormal cases: execution evidence. This is explicitly evidence for that earlier head.
  • Current-head CI run 34942207662 has successful Ubuntu UT, SCA, coverage, Compose Proxy BVT, Standalone Pessimistic BVT and CI Required checks. Ordinary CI success does not establish the performance acceptance criteria.
  • Traceable maintainer approval of the design revision, the original nightly ADD/DROP workload, paired baseline/head measurements with 1/2/4/8 workers, and QA remain open. The conditional internal handoff review is not maintainer design approval.

This comment clarifies the original questions; it does not declare your review resolved or request another review. The PR description still contains stale head/Draft/CI wording; the current-head evidence above supersedes that old status text.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design-gated re-review at b3b000b.

The required design decision and acceptance evidence remain open. This is a cross-subsystem transaction/snapshot/retry/lifecycle refactor, not merely moving one lock. I read the complete current publication design, its handoff record, and the review/author history. docs/design/20260911-copy-alter-publication-review.md explicitly says its conditional handoff is not maintainer approval and leaves the blocking design decision unresolved.

The design also explicitly requires the original nightly ADD/DROP workload and paired baseline/head measurements at 1/2/4/8 workers before merge, with copy-count, throughput/P95, <=10% single-worker regression and no unexpected timeout/connection-failure criteria. No completion evidence for those gates was found. Current CI is green, but does not replace the specified workload acceptance.

Please record a traceable maintainer decision on the exact current design and provide the required workload/performance evidence or a policy-owner decision changing those acceptance conditions. The executable ALGORITHM=COPY BVT is now present; I am not repeating the historical missing-syntax finding. This is a design/acceptance gate review, not a fresh full implementation approval or a claim of a newly reproduced runtime bug.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Revision 2 is pushed at de39bce1a591d5d85d97b6623e9c32ba50aeefc6 and the PR remains Ready.

Addressed in this head:

  • ordinary publication contention now waits uniformly for ordinary SQL, text/binary prepared execution, and independent executor entry points, so the prepared relation is reused without recopying;
  • the executor/prepared retry-owner wait split was removed; the private coordination marker still owns the bounded complete retry;
  • the binary prepared regression now injects a real coordination conflict and asserts two transaction IDs, complete cleanup, and prepared database/parameter reuse;
  • the owner interleaving regression starts without a pre-existing Snapshot/PITR owner;
  • the design and handoff records now identify revision 2 and the SNAPSHOT -> View / ordinary-wait contract.

Fresh local evidence for this head is recorded in the PR body: focused issue regressions, affected package tests, targeted and owning-package race tests, CGo-aware build/vet, and git diff --check pass. The maintainer design decision, original nightly ADD/DROP workload with paired 1/2/4/8-worker measurements, current-head distributed BVT comparison, and deployment QA remain explicit open gates. I am not treating this progress update or the new CI run as approval or QA completion.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Updated at exact head 5be67e3694712bc208e42c8db4c6032a2d896f65 (Ready; no merge/issue closure).

  • Added the revision-3 protocol/evidence package and the pending acceptance-scope proposal. The protocol is SNAPSHOT -> View; ordinary publication contention waits and reuses prepared work, while only the private coordination marker can request one complete retry.
  • Split the refresh terminal regression into 12 independent top-level race tests. The exact selection passed: 12/12, longest terminal event 11.32s, package 25.355s. The high-repetition adaptive sweep remains PARTIAL because the tasks-published case timed out during cleanup under stress and later repetitions were stopped for disk/external admission limits.
  • Added the versioned issue28319_perf driver. Candidate-only 8192-row/2-worker/80-ALTER screening passed for query, text prepared, binary prepared and independent executor: 80 records, 80 copy starts, 80 completions, 0 errors in each mode. These are diagnostics, not baseline/head proof.
  • Formal paired performance, exact original nightly replay, current-head BVT, maintainer design decision and deployment QA remain open and are marked NOT_RUN/`BLOCKED_ENVIRONMENT` in the validation matrix and QA handoff. The historical 31/31 BVT at de39bce1a5 is retained as historical evidence.

Please review the exact revision-3 protocol and decide whether the focused merge-before performance scope is acceptable; no reviewer re-request is being made by this update.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@cpegeric @LeftHandCold — please make an explicit design decision on revision 4, before production repair or implementation re-review.

The exact revision-4 design is published at 56a4c48def089624f2dc1572ec8ea616399db843. This commit changes four design/evidence documents only; executable sources remain identical to f7903a01aa528bb05b5662d6b2bdd859cf4212f5. The PR stays Draft and conflicting. Inspected main is 8795f3699b40504376343fa1acda8b4619f0c76e.

Please approve this coupled protocol, or identify the specific changes required:

  1. Limit the first fast path to ordinary unprotected permanent-table ADD/DROP PRIMARY KEY COPY in a fresh, statement-owned pessimistic RC transaction. Reuse main's scalar replacement admission: retain shared C/G/D, followed by exclusive source K/T, through the transaction. Copying avoids global exclusive protection; it does not run without lifecycle locks.
  2. In that certified narrow domain only, omit the no-op SNAPSHOT UPDATE that would upgrade G. No late G-X acquisition or post-copy snapshot advance/rewind. Unsupported/complex tables and enabled persistent View refresh retain main's broad protocol and its write barrier. Nested CREATE/DROP may borrow only an exact transaction/actor/source/replica-bound receipt.
  3. If final narrow admission discovers changed identity/protection, fully roll back before any copy, then allow at most one fresh broad attempt within the original deadline. Ordinary contention does not recopy; no automatic replay after copying begins or commit outcome becomes uncertain.
  4. Retain all acceptance gates: deterministic actual-path/independent-table proof, 1/2/4/8 workers, <=45.55s per changed top-level race test in Ubuntu CI, three equivalent fixed reconstructed nightly replays, and QA. The old revision-3 proposal to defer 4/8 workers is withdrawn.

The decision record, assertion matrix and runner preparation distinguish proposed work from execution. The successful personal Ubuntu run tested old 8a4c84f4/5be67e36; its runner lifecycle can be reused after rebuilding/updating observations, but its performance is not evidence for this revision. Fixed nightly reconstruction was already accepted; new-head runtime/deployment receipts remain required.

This decision request addresses the design obligations in aptend's thread, XuPeng-SH's first design thread, and the repeated design thread. All remain open until their approval/acceptance requirements are actually met. The two race-budget threads also remain open; no current-head timing is claimed.

Please bind the decision to revision 4 / 56a4c48def089624f2dc1572ec8ea616399db843 and state any conditions. Implementation repair and conflict integration will follow that decision. This is not a request to approve the current implementation or resolve existing reviews.

Copy link
Copy Markdown
Collaborator Author

I am withdrawing the production publication/retry protocol in this PR. Current main has its own COPY ALTER preparation, publication and refresh mechanisms; this is not a claim that the old protocol received design approval or that #28319 has passed performance acceptance.

The regression-only draft #32395 carries independent ADD/DROP PRIMARY KEY SQL scenarios and the historical-read/View/allocator/FK/rollback BVT. Its executor observer demonstrates the stated SQL boundaries; physical write overlap and complete physical-copy/retry counts remain open. The old specialized fixture and gossip network-family changes are recorded as separate candidates and are not included in the new PR; the old performance runner and measurements remain historical experiment material.

For the earlier question about the SQL: COPY ALTER is existing ALTER TABLE ... ALGORITHM=COPY syntax, not a new SQL command. The replacement BVT explicitly executes ADD and DROP PRIMARY KEY with that syntax; its local normal comparison passed 31 statements. The new head's Ubuntu race timing and CI remain pending.

The fixed B/M performance comparison, three distributed nightly replays, cleanup and QA remain to be tracked under #28319. I have replied separately to the five outstanding inline threads. I am closing this old implementation in favor of the regression draft; the issue stays open.

This branch had an error being deployed

1 failed deployment
ci — 56a4c48d Deployed Oct 15, 2026 by VioletQwQ-0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/enhancement kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants