Skip to content

Commit 81d7c79

Browse files
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, @gouhongshen
1 parent 4389315 commit 81d7c79

20 files changed

Lines changed: 3427 additions & 112 deletions

pkg/common/moerr/cause.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ var (
104104
CauseAllocateTasks = NewInternalError(context.Background(), "allocateTask")
105105
CauseTruncateTasks = NewInternalError(context.Background(), "truncateTasks")
106106
//pkg/incrservice
107-
CauseDoAllocate = NewInternalError(context.Background(), "doAllocate")
108-
CauseDoUpdate = NewInternalError(context.Background(), "doUpdate")
109-
CauseDestroyTables = NewInternalError(context.Background(), "destroyTables")
110-
CauseAllocate = NewInternalError(context.Background(), "allocate")
107+
CauseDoAllocate = NewInternalError(context.Background(), "doAllocate")
108+
CauseDoUpdate = NewInternalError(context.Background(), "doUpdate")
109+
CauseDoForceSetOffset = NewInternalError(context.Background(), "doForceSetOffset")
110+
CauseDestroyTables = NewInternalError(context.Background(), "destroyTables")
111+
CauseAllocate = NewInternalError(context.Background(), "allocate")
111112
//pkg/lockservice
112113
CauseCleanCommitState = NewInternalError(context.Background(), "cleanCommitState")
113114
CauseValidateService = NewInternalError(context.Background(), "validateService")

pkg/common/moerr/cause_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ var causeArray = []error{
9898

9999
CauseDoAllocate,
100100
CauseDoUpdate,
101+
CauseDoForceSetOffset,
101102
CauseDestroyTables,
102103
CauseAllocate,
103104

pkg/frontend/test/incrservice_mock.go

Lines changed: 129 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)