Skip to content

fix(dolt): reset AUTO_INCREMENT after DOLT_PULL#2135

Merged
steveyegge merged 2 commits intosteveyegge:mainfrom
cameronraysmith:2133-reset-autoincrement-after-pull
Feb 26, 2026
Merged

fix(dolt): reset AUTO_INCREMENT after DOLT_PULL#2135
steveyegge merged 2 commits intosteveyegge:mainfrom
cameronraysmith:2133-reset-autoincrement-after-pull

Conversation

@cameronraysmith
Copy link
Contributor

@cameronraysmith cameronraysmith commented Feb 25, 2026

Fixes #2133.

This PR adds a resetAutoIncrements function that sets AUTO_INCREMENT = MAX(id) + 1 on all six AUTO_INCREMENT tables after a successful DOLT_PULL. It is applied in both the authenticated and unauthenticated code paths of Pull(), which backs bd dolt pull.

The issue also considered applying the fix after DOLT_MERGE, but testing showed dolt correctly tracks AUTO_INCREMENT for intra-server branch merges. The bug only manifests when rows arrive from a remote via DOLT_PULL, where the server's local counter is not reconciled with the merged data. The previously applied merge fix was dropped since it could not be reproduced.

  • TestAutoIncrementAfterPull (integration): source pushes, CLI clone adds AUTO_INCREMENT rows and pushes back, source pulls, verifies post-pull CreateIssue succeeds
Failure without fix
=== RUN   TestAutoIncrementAfterPull
    git_remote_test.go:968: CreateIssue after pull failed (AUTO_INCREMENT not reset?): failed to record creation event: Error 1062 (HY000): duplicate primary key given: [2]
--- FAIL: TestAutoIncrementAfterPull (6.18s)
FAIL

@cameronraysmith cameronraysmith marked this pull request as ready for review February 25, 2026 23:43
@cameronraysmith cameronraysmith force-pushed the 2133-reset-autoincrement-after-pull branch from 59ceba0 to 2ee27c5 Compare February 26, 2026 03:46
@cameronraysmith cameronraysmith marked this pull request as draft February 26, 2026 04:36
@cameronraysmith cameronraysmith force-pushed the 2133-reset-autoincrement-after-pull branch from 2ee27c5 to b584e74 Compare February 26, 2026 04:50
@cameronraysmith cameronraysmith marked this pull request as ready for review February 26, 2026 04:57
@cameronraysmith cameronraysmith force-pushed the 2133-reset-autoincrement-after-pull branch from b584e74 to b5c5e49 Compare February 26, 2026 05:04
@cameronraysmith cameronraysmith changed the title fix(dolt): reset AUTO_INCREMENT after DOLT_PULL and DOLT_MERGE fix(dolt): reset AUTO_INCREMENT after DOLT_PULL Feb 26, 2026
@steveyegge steveyegge merged commit a138db4 into steveyegge:main Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stale AUTO_INCREMENT after DOLT_PULL causes duplicate key errors

2 participants