Skip to content

AUTO_INCREMENT not synced after primary/standby failover, causing duplicate key errors #9725

@zhijun714

Description

@zhijun714

When performing a failover in a Dolt high-availability setup using dolt_assume_cluster_role('primary', ...), the AUTO_INCREMENT counter on the new primary is not updated to reflect the current max primary key value in the table.

What happens
1. The old primary has inserted rows with AUTO_INCREMENT primary keys (e.g., IDs up to 100).
2. These rows are replicated to the standby node as expected.
3. After failover, the new primary starts generating IDs from its previous AUTO_INCREMENT value (e.g., 50), which causes:。
ERROR 1062 (23000): Duplicate entry '101' for key 'PRIMARY'

Expected behavior
After failover, the new primary should automatically adjust the AUTO_INCREMENT counter for each table so that:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions