Skip to content

fix: refresh ALTER COPY after concurrent source writes - #31435

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/fd24dbc9cd09c4419659808819198cec6deb08a9a8a65355b180f47689e578c3
Oct 27, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/fd24dbc9cd09c4419659808819198cec6deb08a9a8a65355b180f47689e578c3

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

What this PR does / why we need it:

ALTER COPY prepares before its lifecycle gate. When an in-flight LOAD commits while ALTER waits, the prepared copy is stale and the first ALTER currently fails with a transaction write conflict.

For pessimistic RC transactions, retire the complete transaction-owned private generation and prepare once more at the locked fresh frontier in the same transaction. Keep caller-local writes, allocator generations, partition indexes and lineage consistent; preserve real source-definition and lock conflicts. Errors after refresh, including publication retries, remain terminal so COPY cannot restart a third time.

Normal ALTER still prepares once before the gate. Recovery adds one full copy and index preparation while holding the gate, which can delay other lifecycle DDL.

Validation: owning compile package in normal and race modes; deterministic LOAD/ALTER and transaction regressions (PK/no-PK, commit/rollback/borrowed writes, cancellation, private-generation and publication failures, partitions/allocator, plugin task isolation, lineage, FK/GRANT); existing ordering/FastFail/tombstone controls; focused race repetition; scoped static checks. Extended alter_copy_add_index BVT passed ordinary comparison twice on the same instance, 95/95 statements each with teardown checks. Full Linux/distributed CI remains pending.

Leave the issue open for the reporter to verify after merge.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 063f25a4c338f171acc90c9786121a867319d386

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 063f25a4c338f171acc90c9786121a867319d386

Assessment: approve

Reviewed the complete six-file delta, linked issue and frozen discussion. The single refresh reuses established admission, snapshot, preparation and cleanup owners, preserves caller-local writes, and prevents further COPY retries after refresh failure. No actionable unresolved findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Reused frozen exact-head successes for Ubuntu UT, arm64 SCA, shared build, UT coverage, proxy and pessimistic multi-CN BVT, and CI Required.

  • Reviewed three focused helper tests, 19 deterministic integration scenarios, and the SQL/result additions covering defaults, rollback, partition indexes and allocator progression.

  • Saved discussion-assessment.json covering both informational discussion items; no prior substantive findings or rebuttals exist.

  • Source/evidence audit passed with unchanged source. Receipt: /home/xupeng/.local/state/mo-bot/jobs/4e76de6c731dcec1ed7d558c/attempt-1/checks/1793100839365771007-4.json; corresponding review-audit.log and check-ledger.json are retained.

Limitations:

  • No local product tests were rerun. Frozen CI metadata lacks per-test logs; additional author-reported race repetitions and BVT runs were not independently certified.

  • The original large-load reproduction was not repeated. Recovery deliberately performs one additional full copy under the lifecycle gate; its latency and resource costs were not benchmarked.

@mergify mergify Bot added the queued label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Matrixone Compose CI execution / multi cn e2e bvt test docker compose(PROXY) fails with this pull request

1 h 6 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Tue 27 Oct, 11:35 · rule main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in place
  • 🚫 Left the queue 12:40 · 8d20652

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, comment @mergifyio queue to queue it again as it is.
Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot removed the dequeued label Oct 27, 2026
@XuPeng-SH
XuPeng-SH merged commit 043fc9d into matrixorigin:main Oct 27, 2026
26 checks passed
XuPeng-SH pushed a commit that referenced this pull request Oct 27, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

- #31401

## What this PR does / why we need it:

Follow-up to merged #31435. Its source refresh lets the first ALTER
succeed after an in-flight LOAD commits, but the extra full preparation
holds the global SNAPSHOT exclusive lifecycle gate and delays unrelated
lifecycle operations.

Certify pure scalar ADD COLUMN in the planner and revalidate source,
target, private ownership, FK/history and the actual nested CREATE
before allowing shared admission through refresh and publication.
Preserve preparation before source locking, caller-local writes,
allocator state and bounded generations. Carry the retained-ownership
FastFail policy through component/name admission; fresh/private-only
owners still wait. Late protection uses FastFail promotion/domain
acquisition; definition races remain terminal. Existing primary keys and
auto-increment columns are supported. Complex, indexed, partitioned, FK
and protected-history tables retain the previous broad path and its
cost. Shared admission still delays exclusive owners; this change does
not remove the extra copy or claim a numeric latency/IO improvement.

Validation: deterministic old-code convoy counterexample; real frontend
same-/cross-account and prepared progress, LOAD,
transaction/rollback/cancellation/failure and late-protection controls;
owning compile normal/race and planner normal; focused adaptive race
repetitions; scoped vet/lint. Existing `ddl/alter_copy_add_index` passed
normal mo-tester comparison twice on one embedded two-CN instance, 95/95
statements each, with teardown checks. Full Linux/compose CI remains
pending. Exact MySQL return-latency parity was not measured.

Leave the issue open for reporter verification after merge.

CI repair validation (`7906a005f7f5abc8bec6c79eba5d54e911a6e937`): the
[PROXY
BVT](https://github.com/matrixorigin/matrixone/actions/runs/40570011042/job/122427364748)
and [pessimistic
BVT](https://github.com/matrixorigin/matrixone/actions/runs/40570011042/job/122427364772)
exposed deterministic scalar CREATE certification failures. Recognize
NOT NULL encoded in `Default.NullAbility` and normalize only nested
expression `Type.Table` lineage on cloned trees; preserve default
values, nullability, bound function IDs, column coordinates and semantic
types. Coverage and CI Required failed downstream of these BVT failures.

New checks: both added regression groups fail before their respective
fixes; full compile package (`mo-cgo-test -v -count=1 -timeout=180s
./pkg/sql/compile`) passes. All four Issue31401 integration tests pass,
including the strengthened NOT NULL refresh/progress case, retained
locks, transaction cleanup and LOAD. All ten failed BVT scripts pass
normal comparison on one embedded two-CN instance (2808 executed
statements, 10 existing ignored); expression-default and SHOW CREATE
scripts also pass twice on the same instance, with expression-case
database teardown verified. Scoped `go vet` and `golangci-lint` pass for
compile/issues; formatting, license headers and delivery artifact checks
pass. Prior unchanged functional evidence is reused. Local validation is
Darwin/arm64, not Linux Compose/PROXY parity; full CI for this repair is
pending. The preceding exact-head run passed Linux UT, UT coverage and
SCA, including the earlier license repair.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
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 size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants