Bug #42396 autoincrement insert into ndb fails with duplicate key
Submitted: 27 Jan 2009 21:35 Modified: 18 Jan 2017 13:21
Reporter: Andrei Elkin Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Cluster: Replication Severity:S3 (Non-critical)
Version:mysql-6.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: 6.0-rpl, disabled
Triage: Triaged: D2 (Serious) / R6 (Needs Assessment) / E6 (Needs Assessment)

[27 Jan 2009 21:35] Andrei Elkin
Description:
a modified version of rpl_ndb_circular_2ch after applying fixes for 
http://lists.mysql.com/commits/64067
http://lists.mysql.com/commits/64068
fails in 6.0-rpl tree.

Trying to narrow down a possible issue it was found out that some number of inserts through one of connection to the master clusters like

let $counter= 30;

while ($counter) {
 --connection master1
 INSERT INTO t1(b,c) VALUES('master1',2);
 dec $counter;
}

eventually hit
ERROR 1022 (23000): Can't write; duplicate key in table ''

Appling the aforementioned patches to rpl_ndb_circular_2ch.{cnf,test}
and executing the test gets:

CURRENT_TEST: rpl_ndb.rpl_ndb_circular_2ch
mysqltest: At line 107: query 'COMMIT' failed: 1022: Can't write; duplicate key in table ''

I assume this is rather the cluster problem than cluster-replication, because
in the quoted loop there is only one connection that is active. Nothing is being
applying on the master's mysqld through replication while the loop executes. The test code should rule out that possibility as well as my visual check of the relay-log files.
Replication is somehow involved, moreover it should be circular. my testing with one-way master->slave did not reveal anything.

How to repeat:
See the attached files rpl_ndb_x.{cnf,test}. Or apply the aforementioned patches to rpl_ndb_circular_2ch.{cnf,test} and run it

./mtr --mysqld=--binlog-format=row --no-check-testcase --no-warnings  test

to see

mysqltest: At line 97: query 'INSERT INTO t1(b,c) VALUES('master1',2)' failed: 1022: Can't write; duplicate key in table ''

for rpl_ndb_x.test.

or 

mysqltest: At line 107: query 'COMMIT' failed: 1022: Can't write; duplicate key in table ''

for rpl_ndb_circular_2ch

To ease catching the exact INSERT that fails I suggest to uncomment --sleep left
right atop of the loop in rpl_ndb_x.test, fire a connection to the second mysqld of the master cluster, execute first queries 
SET auto_increment_offset = 1; SET auto_increment_increment = 2;
and then start inserting as the referred loop does.
It took about 24 to 25 for me to get to the dup error.
[27 Jan 2009 21:37] Andrei Elkin
the conf file for the test

Attachment: rpl_ndb_x.cnf (application/octet-stream, text), 365 bytes.

[27 Jan 2009 21:38] Andrei Elkin
a bit stripped version of rpl_ndb_circular_2ch

Attachment: rpl_ndb_x.test (application/octet-stream, text), 2.87 KiB.

[18 Jan 2017 10:31] Miguel Solorzano
It'is this bug still valid for today server versions it was filed against mysql-6.0 or could be closed?. Thanks.
[18 Jan 2017 11:11] Andrei Elkin
Miguel,

I think one needs to run

  rpl_ndb_x.test  (take note of the cnf file)

and see whether the dup error still shows up.

Regards,

Andrei