Duplicate PRIMARY KEY errors after changing auto_increment settings

Bug #1572157 reported by monty solomon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server moved to https://jira.percona.com/projects/PS
Incomplete
Undecided
Unassigned

Bug Description

We are getting duplicate primary key errors after changing the auto_increment settings.

We were inserting rows into tables in two (2) databases on separate servers and changed the auto_increment settings on the servers so one of them would use odd values and the other one would use even values for a migration where we didn't want any collisions.

The migration is complete and we changed the auto_increment settings back to the default values and are getting duplicate primary key errors for some INSERT statements.

Tags: upstream
Revision history for this message
monty solomon (monty+launchpad) wrote :

How to repeat:

Change the auto_increment settings to use even values and insert many rows into several tables.

SET GLOBAL auto_increment_increment = 2 ; SET GLOBAL auto_increment_offset = 2 ;

Change the auto_increment settings back to the standard values and insert rows into the tables.

SET GLOBAL auto_increment_increment = 1 ; SET GLOBAL auto_increment_offset = 1 ;

Observe duplicate primary key errors for some INSERT statements.

Revision history for this message
monty solomon (monty+launchpad) wrote :

mysql Ver 14.14 Distrib 5.6.25-73.1, for Linux (x86_64) using 6.0
5.6.25-73.1-log Percona Server (GPL), Release 73.1, Revision 07b797f

Revision history for this message
monty solomon (monty+launchpad) wrote :
Revision history for this message
monty solomon (monty+launchpad) wrote :

An INSERT failed today complaining about a duplicate PRIMARY KEY for an entry that was added three (3) days ago.

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1436' for key 'PRIMARY' [statement:"INSERT INTO subscription_items

The entry with the id 1436 was created at 160416 1:50:56 Z and the failure was today at 160419 11:53:16 Z.

Revision history for this message
monty solomon (monty+launchpad) wrote :

It appears that the auto increment is working better after a server restart.

Something may be in a weird state after the dynamic changes.

tags: added: upstream
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

The upstream bug was marked as a duplicate of https://bugs.mysql.com/bug.php?id=76872, which was closed as fixed in 5.6.35. Can you test?

Changed in percona-server:
status: New → Incomplete
Revision history for this message
monty solomon (monty+launchpad) wrote :

We are running 5.7 and haven't upgraded to 5.7.17 yet.

Revision history for this message
monty solomon (monty+launchpad) wrote :

This bug affects versions 5.6 and 5.7.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-3413

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.