Repository navigation
Conversation
Co-authored-by: ULookup <[email protected]>
…uto-increment-epoch-fence
Co-authored-by: ULookup <[email protected]>
Co-authored-by: ULookup <[email protected]>
…uto-increment-epoch-fence
This was referenced Jul 22, 2026
VioletQwQ-0
marked this pull request as ready for review
July 22, 2026 10:25
VioletQwQ-0
requested review from
XuPeng-SH,
aptend,
aunjgr and
gouhongshen
as code owners
July 22, 2026 10:25
2 tasks done
XuPeng-SH
added a commit
that referenced
this pull request
Jul 23, 2026
## What type of PR is this? - [x] BUG - [x] Test and CI ## What this PR does / why we need it This PR fixes two independent nondeterministic test setups without relaxing production behavior. ### TAE checkpoint replay TestAppendAndGC2 created its database and tables through low-level TAE catalog APIs. Those APIs mutate the in-memory catalog but do not append rows to mo_database, mo_tables, and mo_columns. After a forced checkpoint truncates the DDL WAL, checkpoint replay can therefore lose the still-live database. The prepared-DML replay fence added by #26027 exposed this invalid setup as ExpectedEOB. The previous version of this PR skipped missing catalog entries, but diagnostics proved the missing IDs were the live test database and table. That production-code relaxation was removed. The test now uses the full DDL helpers and, after restart, opens both relations and scans every column to verify that each still contains all 99 rows. ### Shard read compatibility test TestReadValidatesAllRemoteShardsBeforeSending could create its table before all three CNs reported to the shard server. In the failed Ubuntu job, all shards were initially allocated to cn1 and balancing the second shard took 60 seconds. The shared setup context expires after 10 seconds, so the first remote compatibility check returned context deadline exceeded after one Adjust call instead of reaching the intended incompatible CN. The test now waits for every CN before creating shards, bounds every replica wait, uses separate setup and read contexts, and asserts the exact incompatibility error. This keeps the test fast and prevents unrelated timeout errors from satisfying require.Error. No production code is changed. ## Validation - TAE focused replay test: count=20 - TAE focused replay test: race count=10 - pkg/vm/engine/tae/db/test full package - pkg/vm/engine/tae/txn/txnimpl full package - shard compatibility test: count=30 - shard compatibility test: race count=10 - pkg/shardservice full package - go build ./pkg/shardservice - go vet ./pkg/shardservice - git diff --check
4 of 7 tasks
mergify Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
This is the next prerequisite after #26027. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant in this PR is that an AUTO_INCREMENT offset reset and its allocator-cache transition belong to the same transaction: - the resetting transaction sees its pending offset without publishing it to other transactions; - statement or transaction rollback retires the private reset cache; - commit publishes a cache for the allocation epoch actually used by the write; - stale builders and old cache generations cannot become active after reset/reload/close; - accepted allocator actions drain during close, while a canceled queued reset cannot mutate the store. The shared service interface now carries `autoIncrEpoch` and `TxnOperator` through both production allocation callers. `memStore` and `sqlStore` gain monotonic `SetOffset` plus DDL-constrained `ForceSetOffset`; all implementations and mocks are updated atomically. Out of scope for this PR: - planner/compiler support for the user-facing ALTER syntax; - COPY/CLONE allocator reconciliation; - rolling-upgrade enablement for mixed-version TNs; - end-to-end BVT for the final SQL behavior. Diff size, separated for reviewability: - production: `+1303 / -86` - tests: `+1832 / -8` - mocks: `+292 / -18` Validation: - `go test -race ./pkg/incrservice -count=1` - `go test ./pkg/sql/colexec/preinsert ./pkg/sql/colexec/table_clone ./pkg/frontend/test ./pkg/vm/engine/test/testutil -count=1` - `go test ./pkg/... -run '^$'` - `git diff --check` - exact-head `mo-pr-preflight-review`: PASS at `891781d3a927b80b54d38e381ebee0d749c1c589` Approved by: @XuPeng-SH, @gouhongshen
1 of 4 tasks
XuPeng-SH
pushed a commit
that referenced
this pull request
Jul 28, 2026
issue #23143 ## What type of PR is this? - [x] bug - [ ] feature - [ ] improvement - [ ] documentation ## What this PR does / why we need it: This is the next serial prerequisite in the #25883 split. It makes COPY/CLONE allocator reconciliation independently correct before the user-facing `ALTER TABLE ... AUTO_INCREMENT=N` entry is enabled. Invariant: - a visible destination allocator is reset to `max(requested offset, copied-row maximum, source allocator offset)`; - fresh CLONE maps allocator state by cloned column name because planner IDs are in a new coordinate space; - ALTER COPY maps retained columns by stable `ColId`, preserving rename/reorder and preventing a dropped-and-readded same-name column from inheriting old state; - hidden fake-PK allocators remain independent from visible AUTO_INCREMENT requests; - failed/cancelled ALTER COPY statements discard transaction-private resets, and all internal SQL results are closed. ## Changes - collect source allocator offsets and visible row maxima at the selected snapshot/account; - translate source catalog indexes to destination identities before execution; - replace fake value insertion with transaction-aware `SetOffset`; - reconcile temporary ALTER COPY tables after copied rows become visible in the DDL transaction; - validate destination signed/unsigned integer bounds before resetting; - add regression coverage for fresh ID collisions, rename/reorder, drop/add name reuse, hidden allocators, three-way bounds, overflow, cancellation, rollback cleanup, quoted identifiers, and error-result cleanup; - add an issue-linked distributed case that snapshots the real source allocator offset and proves COPY ALTER preserves its reserved range. ## Non-goals - no `ALTER TABLE ... AUTO_INCREMENT=N` SQL entry; - no mixed-version enablement gate; - no change to the epoch attached to allocated writes; - no generic transaction/recovery changes. ## Testing - `go test ./pkg/incrservice ./pkg/sql/colexec/table_clone ./pkg/sql/compile -count=1` - focused `-race` runs for the new incrservice, table_clone, and compile tests - `go test ./pkg/... -run '^$'` - dedicated `issue_23143_copy_auto_increment` distributed regression added; fresh CI execution is pending for the current head - `git diff --check` - `mo-self-review`: PASS - exact-head `mo-pr-preflight-review`: `PASS review=PASS validation=PENDING` for `6b1bb91fa0c292ab056adab3a8ba34935125e9fc` ## Diff size - production code: 5 files, `+416/-99` - tests: 7 files, `+689/-4` - generated code: none ## Dependency Depends on the merged epoch fence (#26027) and transactional allocator reset (#26085). The next split item will start from `main` only after this PR merges. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#23143 ## What this PR does / why we need it: This is the first AUTO_INCREMENT-specific prerequisite split from the closed matrixorigin#25883. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant introduced here is: a CN write carries the AUTO_INCREMENT epoch observed when its values were allocated, and TN accepts the write only when that epoch matches the table epoch. Once a table enters a fenced epoch, legacy writers that cannot provide an epoch fail closed. | Correctness requirement | Change in this PR | | --- | --- | | Preserve the allocator generation across the write path | Persist the epoch in `SchemaExtra` / `plan.TableDef`, propagate it through disttae workspace, row and object writes, flush/compaction, RPC, and TN relations | | Prevent stale cached values from committing after a reset | Validate the known epoch at TN prepare/commit and require every epoch transition to be exactly `current + 1` | | Keep the fence effective after restart | Rebuild committed DML watermarks during replay and keep prepared replay transactions fenced until commit or rollback | | Remain compatible before the feature is enabled | Treat an unknown legacy epoch as zero only while the table epoch is zero; after the first reset, unknown writers are rejected | Additional guards reject epoch exhaustion before mutation and keep ordinary schema ALTER operations from advancing the AUTO_INCREMENT epoch. ### Explicit non-goals - no allocator offset/cache reset API; - no COPY/CLONE allocator reconciliation; - no user-facing `ALTER TABLE ... AUTO_INCREMENT=N` planner or compile entry point; - no generic prepared/committing 2PC recovery redesign. The independent TN route/cancellation prerequisite was merged in matrixorigin#25956. ### Diff size - handwritten code and tests: 23 files, `+1283/-131`; - generated protobuf code: 2 files, `+1565/-1079`; - total: 25 files. Proto sources and generated files are committed together. ### Validation - `go test ./pkg/vm/engine/disttae ./pkg/vm/engine/tae/catalog ./pkg/vm/engine/tae/rpc ./pkg/vm/engine/tae/txn/txnimpl ./pkg/vm/engine/tae/db/test` - focused `-race` coverage for epoch transitions and replay commit/rollback lifecycle - protobuf regeneration stability check - `git diff --check` - `mo-pr-preflight-review`: PASS at exact head `4122a7add078c79757121a4add2d8771113c7980` - `mo-self-review`: no open blocker The PR is intentionally Draft while its full CI runs and while this prerequisite is reviewed independently. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…gin#26051) ## What type of PR is this? - [x] BUG - [x] Test and CI ## What this PR does / why we need it This PR fixes two independent nondeterministic test setups without relaxing production behavior. ### TAE checkpoint replay TestAppendAndGC2 created its database and tables through low-level TAE catalog APIs. Those APIs mutate the in-memory catalog but do not append rows to mo_database, mo_tables, and mo_columns. After a forced checkpoint truncates the DDL WAL, checkpoint replay can therefore lose the still-live database. The prepared-DML replay fence added by matrixorigin#26027 exposed this invalid setup as ExpectedEOB. The previous version of this PR skipped missing catalog entries, but diagnostics proved the missing IDs were the live test database and table. That production-code relaxation was removed. The test now uses the full DDL helpers and, after restart, opens both relations and scans every column to verify that each still contains all 99 rows. ### Shard read compatibility test TestReadValidatesAllRemoteShardsBeforeSending could create its table before all three CNs reported to the shard server. In the failed Ubuntu job, all shards were initially allocated to cn1 and balancing the second shard took 60 seconds. The shared setup context expires after 10 seconds, so the first remote compatibility check returned context deadline exceeded after one Adjust call instead of reaching the intended incompatible CN. The test now waits for every CN before creating shards, bounds every replica wait, uses separate setup and read contexts, and asserts the exact incompatibility error. This keeps the test fast and prevents unrelated timeout errors from satisfying require.Error. No production code is changed. ## Validation - TAE focused replay test: count=20 - TAE focused replay test: race count=10 - pkg/vm/engine/tae/db/test full package - pkg/vm/engine/tae/txn/txnimpl full package - shard compatibility test: count=30 - shard compatibility test: race count=10 - pkg/shardservice full package - go build ./pkg/shardservice - go vet ./pkg/shardservice - git diff --check
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This is the next prerequisite after matrixorigin#26027. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant in this PR is that an AUTO_INCREMENT offset reset and its allocator-cache transition belong to the same transaction: - the resetting transaction sees its pending offset without publishing it to other transactions; - statement or transaction rollback retires the private reset cache; - commit publishes a cache for the allocation epoch actually used by the write; - stale builders and old cache generations cannot become active after reset/reload/close; - accepted allocator actions drain during close, while a canceled queued reset cannot mutate the store. The shared service interface now carries `autoIncrEpoch` and `TxnOperator` through both production allocation callers. `memStore` and `sqlStore` gain monotonic `SetOffset` plus DDL-constrained `ForceSetOffset`; all implementations and mocks are updated atomically. Out of scope for this PR: - planner/compiler support for the user-facing ALTER syntax; - COPY/CLONE allocator reconciliation; - rolling-upgrade enablement for mixed-version TNs; - end-to-end BVT for the final SQL behavior. Diff size, separated for reviewability: - production: `+1303 / -86` - tests: `+1832 / -8` - mocks: `+292 / -18` Validation: - `go test -race ./pkg/incrservice -count=1` - `go test ./pkg/sql/colexec/preinsert ./pkg/sql/colexec/table_clone ./pkg/frontend/test ./pkg/vm/engine/test/testutil -count=1` - `go test ./pkg/... -run '^$'` - `git diff --check` - exact-head `mo-pr-preflight-review`: PASS at `891781d3a927b80b54d38e381ebee0d749c1c589` Approved by: @XuPeng-SH, @gouhongshen
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…26197) issue matrixorigin#23143 ## What type of PR is this? - [x] bug - [ ] feature - [ ] improvement - [ ] documentation ## What this PR does / why we need it: This is the next serial prerequisite in the matrixorigin#25883 split. It makes COPY/CLONE allocator reconciliation independently correct before the user-facing `ALTER TABLE ... AUTO_INCREMENT=N` entry is enabled. Invariant: - a visible destination allocator is reset to `max(requested offset, copied-row maximum, source allocator offset)`; - fresh CLONE maps allocator state by cloned column name because planner IDs are in a new coordinate space; - ALTER COPY maps retained columns by stable `ColId`, preserving rename/reorder and preventing a dropped-and-readded same-name column from inheriting old state; - hidden fake-PK allocators remain independent from visible AUTO_INCREMENT requests; - failed/cancelled ALTER COPY statements discard transaction-private resets, and all internal SQL results are closed. ## Changes - collect source allocator offsets and visible row maxima at the selected snapshot/account; - translate source catalog indexes to destination identities before execution; - replace fake value insertion with transaction-aware `SetOffset`; - reconcile temporary ALTER COPY tables after copied rows become visible in the DDL transaction; - validate destination signed/unsigned integer bounds before resetting; - add regression coverage for fresh ID collisions, rename/reorder, drop/add name reuse, hidden allocators, three-way bounds, overflow, cancellation, rollback cleanup, quoted identifiers, and error-result cleanup; - add an issue-linked distributed case that snapshots the real source allocator offset and proves COPY ALTER preserves its reserved range. ## Non-goals - no `ALTER TABLE ... AUTO_INCREMENT=N` SQL entry; - no mixed-version enablement gate; - no change to the epoch attached to allocated writes; - no generic transaction/recovery changes. ## Testing - `go test ./pkg/incrservice ./pkg/sql/colexec/table_clone ./pkg/sql/compile -count=1` - focused `-race` runs for the new incrservice, table_clone, and compile tests - `go test ./pkg/... -run '^$'` - dedicated `issue_23143_copy_auto_increment` distributed regression added; fresh CI execution is pending for the current head - `git diff --check` - `mo-self-review`: PASS - exact-head `mo-pr-preflight-review`: `PASS review=PASS validation=PENDING` for `6b1bb91fa0c292ab056adab3a8ba34935125e9fc` ## Diff size - production code: 5 files, `+416/-99` - tests: 7 files, `+689/-4` - generated code: none ## Dependency Depends on the merged epoch fence (matrixorigin#26027) and transactional allocator reset (matrixorigin#26085). The next split item will start from `main` only after this PR merges. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#23143 ## What this PR does / why we need it: This is the first AUTO_INCREMENT-specific prerequisite split from the closed matrixorigin#25883. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant introduced here is: a CN write carries the AUTO_INCREMENT epoch observed when its values were allocated, and TN accepts the write only when that epoch matches the table epoch. Once a table enters a fenced epoch, legacy writers that cannot provide an epoch fail closed. | Correctness requirement | Change in this PR | | --- | --- | | Preserve the allocator generation across the write path | Persist the epoch in `SchemaExtra` / `plan.TableDef`, propagate it through disttae workspace, row and object writes, flush/compaction, RPC, and TN relations | | Prevent stale cached values from committing after a reset | Validate the known epoch at TN prepare/commit and require every epoch transition to be exactly `current + 1` | | Keep the fence effective after restart | Rebuild committed DML watermarks during replay and keep prepared replay transactions fenced until commit or rollback | | Remain compatible before the feature is enabled | Treat an unknown legacy epoch as zero only while the table epoch is zero; after the first reset, unknown writers are rejected | Additional guards reject epoch exhaustion before mutation and keep ordinary schema ALTER operations from advancing the AUTO_INCREMENT epoch. ### Explicit non-goals - no allocator offset/cache reset API; - no COPY/CLONE allocator reconciliation; - no user-facing `ALTER TABLE ... AUTO_INCREMENT=N` planner or compile entry point; - no generic prepared/committing 2PC recovery redesign. The independent TN route/cancellation prerequisite was merged in matrixorigin#25956. ### Diff size - handwritten code and tests: 23 files, `+1283/-131`; - generated protobuf code: 2 files, `+1565/-1079`; - total: 25 files. Proto sources and generated files are committed together. ### Validation - `go test ./pkg/vm/engine/disttae ./pkg/vm/engine/tae/catalog ./pkg/vm/engine/tae/rpc ./pkg/vm/engine/tae/txn/txnimpl ./pkg/vm/engine/tae/db/test` - focused `-race` coverage for epoch transitions and replay commit/rollback lifecycle - protobuf regeneration stability check - `git diff --check` - `mo-pr-preflight-review`: PASS at exact head `4122a7add078c79757121a4add2d8771113c7980` - `mo-self-review`: no open blocker The PR is intentionally Draft while its full CI runs and while this prerequisite is reviewed independently. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…gin#26051) ## What type of PR is this? - [x] BUG - [x] Test and CI ## What this PR does / why we need it This PR fixes two independent nondeterministic test setups without relaxing production behavior. ### TAE checkpoint replay TestAppendAndGC2 created its database and tables through low-level TAE catalog APIs. Those APIs mutate the in-memory catalog but do not append rows to mo_database, mo_tables, and mo_columns. After a forced checkpoint truncates the DDL WAL, checkpoint replay can therefore lose the still-live database. The prepared-DML replay fence added by matrixorigin#26027 exposed this invalid setup as ExpectedEOB. The previous version of this PR skipped missing catalog entries, but diagnostics proved the missing IDs were the live test database and table. That production-code relaxation was removed. The test now uses the full DDL helpers and, after restart, opens both relations and scans every column to verify that each still contains all 99 rows. ### Shard read compatibility test TestReadValidatesAllRemoteShardsBeforeSending could create its table before all three CNs reported to the shard server. In the failed Ubuntu job, all shards were initially allocated to cn1 and balancing the second shard took 60 seconds. The shared setup context expires after 10 seconds, so the first remote compatibility check returned context deadline exceeded after one Adjust call instead of reaching the intended incompatible CN. The test now waits for every CN before creating shards, bounds every replica wait, uses separate setup and read contexts, and asserts the exact incompatibility error. This keeps the test fast and prevents unrelated timeout errors from satisfying require.Error. No production code is changed. ## Validation - TAE focused replay test: count=20 - TAE focused replay test: race count=10 - pkg/vm/engine/tae/db/test full package - pkg/vm/engine/tae/txn/txnimpl full package - shard compatibility test: count=30 - shard compatibility test: race count=10 - pkg/shardservice full package - go build ./pkg/shardservice - go vet ./pkg/shardservice - git diff --check
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This is the next prerequisite after matrixorigin#26027. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant in this PR is that an AUTO_INCREMENT offset reset and its allocator-cache transition belong to the same transaction: - the resetting transaction sees its pending offset without publishing it to other transactions; - statement or transaction rollback retires the private reset cache; - commit publishes a cache for the allocation epoch actually used by the write; - stale builders and old cache generations cannot become active after reset/reload/close; - accepted allocator actions drain during close, while a canceled queued reset cannot mutate the store. The shared service interface now carries `autoIncrEpoch` and `TxnOperator` through both production allocation callers. `memStore` and `sqlStore` gain monotonic `SetOffset` plus DDL-constrained `ForceSetOffset`; all implementations and mocks are updated atomically. Out of scope for this PR: - planner/compiler support for the user-facing ALTER syntax; - COPY/CLONE allocator reconciliation; - rolling-upgrade enablement for mixed-version TNs; - end-to-end BVT for the final SQL behavior. Diff size, separated for reviewability: - production: `+1303 / -86` - tests: `+1832 / -8` - mocks: `+292 / -18` Validation: - `go test -race ./pkg/incrservice -count=1` - `go test ./pkg/sql/colexec/preinsert ./pkg/sql/colexec/table_clone ./pkg/frontend/test ./pkg/vm/engine/test/testutil -count=1` - `go test ./pkg/... -run '^$'` - `git diff --check` - exact-head `mo-pr-preflight-review`: PASS at `891781d3a927b80b54d38e381ebee0d749c1c589` Approved by: @XuPeng-SH, @gouhongshen
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…26197) issue matrixorigin#23143 ## What type of PR is this? - [x] bug - [ ] feature - [ ] improvement - [ ] documentation ## What this PR does / why we need it: This is the next serial prerequisite in the matrixorigin#25883 split. It makes COPY/CLONE allocator reconciliation independently correct before the user-facing `ALTER TABLE ... AUTO_INCREMENT=N` entry is enabled. Invariant: - a visible destination allocator is reset to `max(requested offset, copied-row maximum, source allocator offset)`; - fresh CLONE maps allocator state by cloned column name because planner IDs are in a new coordinate space; - ALTER COPY maps retained columns by stable `ColId`, preserving rename/reorder and preventing a dropped-and-readded same-name column from inheriting old state; - hidden fake-PK allocators remain independent from visible AUTO_INCREMENT requests; - failed/cancelled ALTER COPY statements discard transaction-private resets, and all internal SQL results are closed. ## Changes - collect source allocator offsets and visible row maxima at the selected snapshot/account; - translate source catalog indexes to destination identities before execution; - replace fake value insertion with transaction-aware `SetOffset`; - reconcile temporary ALTER COPY tables after copied rows become visible in the DDL transaction; - validate destination signed/unsigned integer bounds before resetting; - add regression coverage for fresh ID collisions, rename/reorder, drop/add name reuse, hidden allocators, three-way bounds, overflow, cancellation, rollback cleanup, quoted identifiers, and error-result cleanup; - add an issue-linked distributed case that snapshots the real source allocator offset and proves COPY ALTER preserves its reserved range. ## Non-goals - no `ALTER TABLE ... AUTO_INCREMENT=N` SQL entry; - no mixed-version enablement gate; - no change to the epoch attached to allocated writes; - no generic transaction/recovery changes. ## Testing - `go test ./pkg/incrservice ./pkg/sql/colexec/table_clone ./pkg/sql/compile -count=1` - focused `-race` runs for the new incrservice, table_clone, and compile tests - `go test ./pkg/... -run '^$'` - dedicated `issue_23143_copy_auto_increment` distributed regression added; fresh CI execution is pending for the current head - `git diff --check` - `mo-self-review`: PASS - exact-head `mo-pr-preflight-review`: `PASS review=PASS validation=PENDING` for `6b1bb91fa0c292ab056adab3a8ba34935125e9fc` ## Diff size - production code: 5 files, `+416/-99` - tests: 7 files, `+689/-4` - generated code: none ## Dependency Depends on the merged epoch fence (matrixorigin#26027) and transactional allocator reset (matrixorigin#26085). The next split item will start from `main` only after this PR merges. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What type of PR is this? - [x] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#23143 ## What this PR does / why we need it: This is the first AUTO_INCREMENT-specific prerequisite split from the closed matrixorigin#25883. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant introduced here is: a CN write carries the AUTO_INCREMENT epoch observed when its values were allocated, and TN accepts the write only when that epoch matches the table epoch. Once a table enters a fenced epoch, legacy writers that cannot provide an epoch fail closed. | Correctness requirement | Change in this PR | | --- | --- | | Preserve the allocator generation across the write path | Persist the epoch in `SchemaExtra` / `plan.TableDef`, propagate it through disttae workspace, row and object writes, flush/compaction, RPC, and TN relations | | Prevent stale cached values from committing after a reset | Validate the known epoch at TN prepare/commit and require every epoch transition to be exactly `current + 1` | | Keep the fence effective after restart | Rebuild committed DML watermarks during replay and keep prepared replay transactions fenced until commit or rollback | | Remain compatible before the feature is enabled | Treat an unknown legacy epoch as zero only while the table epoch is zero; after the first reset, unknown writers are rejected | Additional guards reject epoch exhaustion before mutation and keep ordinary schema ALTER operations from advancing the AUTO_INCREMENT epoch. ### Explicit non-goals - no allocator offset/cache reset API; - no COPY/CLONE allocator reconciliation; - no user-facing `ALTER TABLE ... AUTO_INCREMENT=N` planner or compile entry point; - no generic prepared/committing 2PC recovery redesign. The independent TN route/cancellation prerequisite was merged in matrixorigin#25956. ### Diff size - handwritten code and tests: 23 files, `+1283/-131`; - generated protobuf code: 2 files, `+1565/-1079`; - total: 25 files. Proto sources and generated files are committed together. ### Validation - `go test ./pkg/vm/engine/disttae ./pkg/vm/engine/tae/catalog ./pkg/vm/engine/tae/rpc ./pkg/vm/engine/tae/txn/txnimpl ./pkg/vm/engine/tae/db/test` - focused `-race` coverage for epoch transitions and replay commit/rollback lifecycle - protobuf regeneration stability check - `git diff --check` - `mo-pr-preflight-review`: PASS at exact head `4122a7add078c79757121a4add2d8771113c7980` - `mo-self-review`: no open blocker The PR is intentionally Draft while its full CI runs and while this prerequisite is reviewed independently. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…gin#26051) ## What type of PR is this? - [x] BUG - [x] Test and CI ## What this PR does / why we need it This PR fixes two independent nondeterministic test setups without relaxing production behavior. ### TAE checkpoint replay TestAppendAndGC2 created its database and tables through low-level TAE catalog APIs. Those APIs mutate the in-memory catalog but do not append rows to mo_database, mo_tables, and mo_columns. After a forced checkpoint truncates the DDL WAL, checkpoint replay can therefore lose the still-live database. The prepared-DML replay fence added by matrixorigin#26027 exposed this invalid setup as ExpectedEOB. The previous version of this PR skipped missing catalog entries, but diagnostics proved the missing IDs were the live test database and table. That production-code relaxation was removed. The test now uses the full DDL helpers and, after restart, opens both relations and scans every column to verify that each still contains all 99 rows. ### Shard read compatibility test TestReadValidatesAllRemoteShardsBeforeSending could create its table before all three CNs reported to the shard server. In the failed Ubuntu job, all shards were initially allocated to cn1 and balancing the second shard took 60 seconds. The shared setup context expires after 10 seconds, so the first remote compatibility check returned context deadline exceeded after one Adjust call instead of reaching the intended incompatible CN. The test now waits for every CN before creating shards, bounds every replica wait, uses separate setup and read contexts, and asserts the exact incompatibility error. This keeps the test fast and prevents unrelated timeout errors from satisfying require.Error. No production code is changed. ## Validation - TAE focused replay test: count=20 - TAE focused replay test: race count=10 - pkg/vm/engine/tae/db/test full package - pkg/vm/engine/tae/txn/txnimpl full package - shard compatibility test: count=30 - shard compatibility test: race count=10 - pkg/shardservice full package - go build ./pkg/shardservice - go vet ./pkg/shardservice - git diff --check
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This is the next prerequisite after matrixorigin#26027. It does not expose `ALTER TABLE ... AUTO_INCREMENT=N` yet. The invariant in this PR is that an AUTO_INCREMENT offset reset and its allocator-cache transition belong to the same transaction: - the resetting transaction sees its pending offset without publishing it to other transactions; - statement or transaction rollback retires the private reset cache; - commit publishes a cache for the allocation epoch actually used by the write; - stale builders and old cache generations cannot become active after reset/reload/close; - accepted allocator actions drain during close, while a canceled queued reset cannot mutate the store. The shared service interface now carries `autoIncrEpoch` and `TxnOperator` through both production allocation callers. `memStore` and `sqlStore` gain monotonic `SetOffset` plus DDL-constrained `ForceSetOffset`; all implementations and mocks are updated atomically. Out of scope for this PR: - planner/compiler support for the user-facing ALTER syntax; - COPY/CLONE allocator reconciliation; - rolling-upgrade enablement for mixed-version TNs; - end-to-end BVT for the final SQL behavior. Diff size, separated for reviewability: - production: `+1303 / -86` - tests: `+1832 / -8` - mocks: `+292 / -18` Validation: - `go test -race ./pkg/incrservice -count=1` - `go test ./pkg/sql/colexec/preinsert ./pkg/sql/colexec/table_clone ./pkg/frontend/test ./pkg/vm/engine/test/testutil -count=1` - `go test ./pkg/... -run '^$'` - `git diff --check` - exact-head `mo-pr-preflight-review`: PASS at `891781d3a927b80b54d38e381ebee0d749c1c589` Approved by: @XuPeng-SH, @gouhongshen
VioletQwQ-0
added a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…26197) issue matrixorigin#23143 ## What type of PR is this? - [x] bug - [ ] feature - [ ] improvement - [ ] documentation ## What this PR does / why we need it: This is the next serial prerequisite in the matrixorigin#25883 split. It makes COPY/CLONE allocator reconciliation independently correct before the user-facing `ALTER TABLE ... AUTO_INCREMENT=N` entry is enabled. Invariant: - a visible destination allocator is reset to `max(requested offset, copied-row maximum, source allocator offset)`; - fresh CLONE maps allocator state by cloned column name because planner IDs are in a new coordinate space; - ALTER COPY maps retained columns by stable `ColId`, preserving rename/reorder and preventing a dropped-and-readded same-name column from inheriting old state; - hidden fake-PK allocators remain independent from visible AUTO_INCREMENT requests; - failed/cancelled ALTER COPY statements discard transaction-private resets, and all internal SQL results are closed. ## Changes - collect source allocator offsets and visible row maxima at the selected snapshot/account; - translate source catalog indexes to destination identities before execution; - replace fake value insertion with transaction-aware `SetOffset`; - reconcile temporary ALTER COPY tables after copied rows become visible in the DDL transaction; - validate destination signed/unsigned integer bounds before resetting; - add regression coverage for fresh ID collisions, rename/reorder, drop/add name reuse, hidden allocators, three-way bounds, overflow, cancellation, rollback cleanup, quoted identifiers, and error-result cleanup; - add an issue-linked distributed case that snapshots the real source allocator offset and proves COPY ALTER preserves its reserved range. ## Non-goals - no `ALTER TABLE ... AUTO_INCREMENT=N` SQL entry; - no mixed-version enablement gate; - no change to the epoch attached to allocated writes; - no generic transaction/recovery changes. ## Testing - `go test ./pkg/incrservice ./pkg/sql/colexec/table_clone ./pkg/sql/compile -count=1` - focused `-race` runs for the new incrservice, table_clone, and compile tests - `go test ./pkg/... -run '^$'` - dedicated `issue_23143_copy_auto_increment` distributed regression added; fresh CI execution is pending for the current head - `git diff --check` - `mo-self-review`: PASS - exact-head `mo-pr-preflight-review`: `PASS review=PASS validation=PENDING` for `6b1bb91fa0c292ab056adab3a8ba34935125e9fc` ## Diff size - production code: 5 files, `+416/-99` - tests: 7 files, `+689/-4` - generated code: none ## Dependency Depends on the merged epoch fence (matrixorigin#26027) and transactional allocator reset (matrixorigin#26085). The next split item will start from `main` only after this PR merges. --------- Co-authored-by: ULookup <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23143
What this PR does / why we need it:
This is the first AUTO_INCREMENT-specific prerequisite split from the closed #25883. It does not expose
ALTER TABLE ... AUTO_INCREMENT=Nyet.The invariant introduced here is: a CN write carries the AUTO_INCREMENT epoch observed when its values were allocated, and TN accepts the write only when that epoch matches the table epoch. Once a table enters a fenced epoch, legacy writers that cannot provide an epoch fail closed.
SchemaExtra/plan.TableDef, propagate it through disttae workspace, row and object writes, flush/compaction, RPC, and TN relationscurrent + 1Additional guards reject epoch exhaustion before mutation and keep ordinary schema ALTER operations from advancing the AUTO_INCREMENT epoch.
Explicit non-goals
ALTER TABLE ... AUTO_INCREMENT=Nplanner or compile entry point;Diff size
+1283/-131;+1565/-1079;Validation
go test ./pkg/vm/engine/disttae ./pkg/vm/engine/tae/catalog ./pkg/vm/engine/tae/rpc ./pkg/vm/engine/tae/txn/txnimpl ./pkg/vm/engine/tae/db/test-racecoverage for epoch transitions and replay commit/rollback lifecyclegit diff --checkmo-pr-preflight-review: PASS at exact head4122a7add078c79757121a4add2d8771113c7980mo-self-review: no open blockerThe PR is intentionally Draft while its full CI runs and while this prerequisite is reviewed independently.