Commit 81d7c79
authored
feat(incrservice): add transactional offset resets (#26085)
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, @gouhongshen1 parent 4389315 commit 81d7c79
20 files changed
Lines changed: 3427 additions & 112 deletions
File tree
- pkg
- common/moerr
- frontend/test
- mock_incr
- incrservice
- sql/colexec
- preinsert
- table_clone
- vm/engine/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments