You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: CLONE does not preserve AUTO_INCREMENT state #27092
The same result occurs through CREATE DATABASE clone_ai_dst CLONE clone_ai_src: each of three independent runs retained IDs 1,2,3, but the destination's first inserted row received ID 10001.
A non-clone control with the same table and initial three inserts assigns ID 4 to the next row.
Expected result
The clone should preserve the source table's auto-increment continuation state. With source metadata reporting AUTO_INCREMENT = 4, the first subsequent insert in the cloned table should receive ID 4, as it does in the non-clone control.
Impact
Every cloned auto-increment table deterministically creates a 9,997-value gap for the first post-clone insert. This changes application-visible identifiers and breaks workflows that expect clone data plus its subsequent write behavior to match the source state.
Each source table was only id BIGINT AUTO_INCREMENT PRIMARY KEY, with no inserted rows before CREATE TABLE dst CLONE src. This rules out a collision-avoidance explanation based on copied IDs: cloning even an empty table skips the initial 10,000-value allocation range.
Thus the defect is shared by ordinary table CLONE, database CLONE, and DATA BRANCH CREATE TABLE; a fix should cover the common clone path rather than only the SQL spelling.
Regression and extended verification for #27092 (2026-08-31)
Verification Environment
MatrixOne source: local latest origin/main at 89740fae15dbba2cbe104348659694283cb160a6 — fix(plan): support MySQL JSON defaults and coalesce (#27874).
Related fix: PR #27154, merged as c692afc2799f473c297f38f431810a254fd95981 — fix: preserve clone auto-increment continuation.
Topology: one Log service, one TN service, two CN services, and one Proxy, launched from etc/launch-with-proxy/launch.toml with a fresh, test-owned data directory in an isolated local Docker environment.
Endpoints: Proxy 127.0.0.1:27092, CN-1 127.0.0.1:27093, and CN-2 127.0.0.1:27094.
Client/protocol: MySQL CLI over direct MySQL wire-protocol TCP for the original witness; mo-tester with MySQL Connector/J over the MySQL wire protocol through Proxy for BVT replay.
What Was Covered
OK Original table-clone witness: the exact three-row fixture was run 3 times at each of Proxy, CN-1, and CN-2. Every run returned source_next=4, clone_next=5, and clone_inserted_id=4, rather than the faulty 10001 allocation.
OK Happy path: clone_auto_increment_state.sql passed 65/65; table clone preserves copied rows and the next visible AUTO_INCREMENT value.
OK Alternate clone entry points: database clone, DATA BRANCH CREATE TABLE, and DATA BRANCH CREATE DATABASE all returned the expected continuation state in the dedicated BVT.
OK Boundary scenarios: empty source starts at 1; a source with deleted maximum ID seeds the clone from copied rows; explicit ALTER TABLE ... AUTO_INCREMENT = 100 remains a schema lower bound; transaction and snapshot clone paths passed.
OK Compatibility: standard table clone passed 74/74; permanent-to-temporary destination clone passed 163/163, including the revised contiguous AUTO_INCREMENT expectation.
OK Unhappy-path ownership controls: focused CGo tests passed for fresh-clone allocator reconstruction, ALTER COPY allocator handoff, hidden index allocators, schema rename/reorder mapping, cancellation, and result-error cleanup.
Not covered A concurrent source write racing with clone creation was not separately exercised; the reported deterministic defect concerns fresh-clone allocator initialization, and the fix deliberately does not transfer source CN allocator caches.
Findings
Fresh clones previously copied the source allocator's reserved batch upper bound from mo_catalog.mo_increment_columns. That value was 10000 in the minimal reproduction, although the visible next ID was 4; the fresh destination consequently started at 10001. PR #27154 reconstructs fresh visible allocator state from copied-row maxima and schema lower bounds, while retaining raw allocator transfer where the column-ID ownership model requires it, such as ALTER COPY and hidden internal columns.
MOTR / BVT Coverage
No new MOTR case was added because the merged fix already introduced the dedicated public BVT test/distributed/cases/git4data/clone/clone_auto_increment_state.sql. This verification replayed it (65/65) together with table_clone.sql (74/74) and temporary_table_clone.sql (163/163), without modifying MatrixOne service source or MOTR files.
Final Conclusion
Fixed. Large-data regression is not required: the defect is independent of copied row count and is caused by allocator-state ownership during clone initialization. The deterministic empty/three-row/deleted-maximum/schema-floor fixtures exercise the relevant continuation boundaries; increasing rows would not cover another affected execution state and would add unrelated CI cost.
Activity
Ariznawlll commentedon Aug 13, 2026
Additional confirmation: the defect is independent of copied data volume.
For three independent empty-source table clones:
Each source table was only
id BIGINT AUTO_INCREMENT PRIMARY KEY, with no inserted rows beforeCREATE TABLE dst CLONE src. This rules out a collision-avoidance explanation based on copied IDs: cloning even an empty table skips the initial 10,000-value allocation range.Ariznawlll commentedon Aug 13, 2026
The same state loss affects table-level Data Branch creation.
For three independent runs:
Every run produced:
Thus the defect is shared by ordinary table CLONE, database CLONE, and
DATA BRANCH CREATE TABLE; a fix should cover the common clone path rather than only the SQL spelling.gouhongshen commentedon Aug 17, 2026
PR #27154 is trying to fix this issue.
gouhongshen commentedon Aug 30, 2026
PR #27154 has merged and is awaiting manual validation. The issue remains open.
slyunnn commentedon Aug 31, 2026
Regression and extended verification for #27092 (2026-08-31)
Verification Environment
origin/mainat89740fae15dbba2cbe104348659694283cb160a6—fix(plan): support MySQL JSON defaults and coalesce (#27874).c692afc2799f473c297f38f431810a254fd95981—fix: preserve clone auto-increment continuation.etc/launch-with-proxy/launch.tomlwith a fresh, test-owned data directory in an isolated local Docker environment.127.0.0.1:27092, CN-1127.0.0.1:27093, and CN-2127.0.0.1:27094.mo-testerwith MySQL Connector/J over the MySQL wire protocol through Proxy for BVT replay.What Was Covered
3times at each of Proxy, CN-1, and CN-2. Every run returnedsource_next=4,clone_next=5, andclone_inserted_id=4, rather than the faulty10001allocation.clone_auto_increment_state.sqlpassed65/65; table clone preserves copied rows and the next visible AUTO_INCREMENT value.DATA BRANCH CREATE TABLE, andDATA BRANCH CREATE DATABASEall returned the expected continuation state in the dedicated BVT.1; a source with deleted maximum ID seeds the clone from copied rows; explicitALTER TABLE ... AUTO_INCREMENT = 100remains a schema lower bound; transaction and snapshot clone paths passed.74/74; permanent-to-temporary destination clone passed163/163, including the revised contiguous AUTO_INCREMENT expectation.Findings
Fresh clones previously copied the source allocator's reserved batch upper bound from
mo_catalog.mo_increment_columns. That value was10000in the minimal reproduction, although the visible next ID was4; the fresh destination consequently started at10001. PR #27154 reconstructs fresh visible allocator state from copied-row maxima and schema lower bounds, while retaining raw allocator transfer where the column-ID ownership model requires it, such as ALTER COPY and hidden internal columns.MOTR / BVT Coverage
No new MOTR case was added because the merged fix already introduced the dedicated public BVT
test/distributed/cases/git4data/clone/clone_auto_increment_state.sql. This verification replayed it (65/65) together withtable_clone.sql(74/74) andtemporary_table_clone.sql(163/163), without modifying MatrixOne service source or MOTR files.Final Conclusion
Fixed. Large-data regression is not required: the defect is independent of copied row count and is caused by allocator-state ownership during clone initialization. The deterministic empty/three-row/deleted-maximum/schema-floor fixtures exercise the relevant continuation boundaries; increasing rows would not cover another affected execution state and would add unrelated CI cost.