Skip to content

[Bug]: BIGINT UNSIGNED AUTO_INCREMENT exhaustion returns internal allocation-loop error across CNs #29825

Open

Description

@slyunnn

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open/closed issues for AUTO_INCREMENT + UNSIGNED, 20101, exhaustion and the allocation-loop message on 2026-10-10. The closest reports are closed #26314 (CREATE parser uint64 assertion, before table creation) and #10204 (INT UNSIGNED overflow error value text). This report concerns successful CREATE and inserts followed by BIGINT UNSIGNED allocator exhaustion, not those paths. No clear duplicate found.

Branch Name

main

Commit ID

e5dd472

Runtime on both CNs: git_version() = e5dd4724f7.

Other Environment Information

  • macOS arm64, task-isolated local cluster: two CNs, TN/log service.
  • AUTO_ID_CACHE support enabled on both CNs; direct CN connections on ports 23371/23372, autocommit, default session increment=1/offset=1.
  • Related feature: [Feature Request]: Enhanced AUTO_INCREMENT Support #23371; reviewed test-design case AINC-059 (multi-CN type-limit exhaustion, no duplicate/wraparound, stable failure and healthy service).
  • MOTR execution base: d388866e985572ffb28fc83e719a0df1ec152447, with local diagnostic changes. The diagnostic is not claimed to be merged regression coverage.
  • Exact executed edge-script SHA256: 5ec486f692ddc781b23fecc920f236094dde77010a96cb33bf8315c8e2f97330.
  • This path used PyMySQL directly, not mo-tester expected-result comparison.

Actual Behavior

After the available BIGINT UNSIGNED AUTO_INCREMENT values are exhausted, some requests return the normal out-of-range error, while others enter the allocation-loop guard and return an internal error:

(1690, 'data out of range: data type bigint unsigned, auto_incrment column constant value overflows bigint unsigned')
(20101, 'internal error: AUTO_INCREMENT could not find a value in the requested session series after 8 allocations')

Direct request-by-request reconciliation:

AUTO_ID_CACHE Requests Successful inserts errno 1690 errno 20101
1 160 64 48 48
8 160 64 40 56

Both cases stored exactly 64 distinct IDs in [18446744073709551552, 18446744073709551615]. Every successful writer/request pair matched a stored row. No duplicate IDs, wraparound, or successful writes reported as failed were observed. Each writer's concluding SELECT 1 succeeded.

Scope/stability: seen in two independent cache configurations in one diagnostic execution, with multiple failing requests per configuration and no application retries. Independent repeat rounds were not performed, so this is not a repeated-round reproduction-rate claim. Subsequent extra terminal INSERT controls were not reached because the strict error-code assertion failed; their result is not claimed.

Expected Behavior

A genuinely exhausted unsigned allocator should terminate via its supported exhaustion/out-of-range path, rather than attempting empty allocations until it reports that a value cannot be found in the requested session series. The default session series here is valid (increment=offset=1).

Please confirm the externally supported exhaustion error contract. The observed errno 1690 path is the comparison/control; this report does not assume an independently confirmed MySQL-compatible numeric-error contract. No expected result was relaxed to accept errno 20101.

Steps to Reproduce

The following describes the executed workload, not a newly tested simplified reproducer:

  1. Start the two-CN cluster at the above main SHA and enable AUTO_ID_CACHE. Use a fresh task-owned database. On CN1:
CREATE TABLE t (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  w INT,
  r INT
) AUTO_INCREMENT=18446744073709551552 AUTO_ID_CACHE=1;
SELECT mo_ctl('cn', 'SYNCCOMMIT', '');
  1. Confirm the causal synchronization reports two CNs. Start four fresh autocommit connections (writers 0/2 on CN1, 1/3 on CN2), release them together using a four-party barrier. Each writer executes 40 separate single-row statements, with request IDs 0..39:
INSERT INTO t(w,r) VALUES (<writer_id>, <request_id>);

Capture success or the exact driver errno/message for every request, continuing to the next request after an error without retrying that request. Each writer finishes with SELECT 1.

  1. After all writers finish, synchronize and reconcile:
SELECT mo_ctl('cn', 'SYNCCOMMIT', '');
SELECT id,w,r FROM t ORDER BY id;
  1. In another fresh database, run the same workload with AUTO_ID_CACHE=8. The result is the second row in the table above. Remove only these task-owned databases after retaining evidence.

Additional information

Initial source-level hypothesis, not an internal event trace or a proven complete root cause:

  • getNext / getNextRange: when current is MaxUint64, next remains MaxUint64; step=1 makes both returned bounds wrap to zero, yielding [0,0).
  • store_sql.go uses the same helper to produce the allocated range.
  • applyAllocateLocked handles to < from and to > from, but equal zero bounds do not set overflow/terminal. A cache that already owns the terminal value has a separate overflow path.
  • applyAutoValues eventually hits the eight-allocation guard on the non-overflow path, consistent with the observed 20101 message.

Raw local evidence retained in the originating Feature-testing task: outputs/attempt-12/edges-single/feature_23371_sql.jsonl (SQL and overflow_reconcile records), edges-single-report/failures.txt, both CN logs, exact source snapshot and source-sha256.json. These files are not publicly uploaded by this Issue; the exact error excerpts and reconciled counts are included above. Related functional regression work: matrixorigin/motr#225. The failed diagnostic itself is not part of that PR.

The independent mo-tester comparator bug (matrixorigin/mo-tester#207) and sequence metadata-baseline differences are unrelated to this direct-SQL failure and are not included in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugphase/testing

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions