Bug #47952 Ndb replication : Unique index modifications give slave duplicate key errors
Submitted: 9 Oct 19:09
Reporter: Frazer Clement
Status: Open
Category:Server: ClusterRep Severity:S3 (Non-critical)
Version:mysql-5.1-telco-6.2 OS:Any
Assigned to: Frazer Clement Target Version:
Tags: mysql-5.1-telco-6.2+
Triage: Triaged: D3 (Medium) / R6 (Needs Assessment) / E6 (Needs Assessment)

[9 Oct 19:09] Frazer Clement
Description:
Row events in the Ndb Binlog are ordered according to the partitioning of the 'base'
table, and may appear in a different order within an epoch than they were executed in.

Where the base table has unique index(es), this re-ordering of events can result in
duplicate key errors when the binlog is executed.

How to repeat:
--source include/have_ndb.inc
--source include/have_binlog_format_mixed_or_row.inc
--source include/ndb_master-slave.inc

#
# Slave behaviour when replicating unique index operations
#
#

--connection master

CREATE TABLE t1 (pk int primary key, uk int, unique(uk)) engine=ndb;

# Now perform some operations which do not result in uniqueness
# violations when applied in-order, but which can result in them
# when applied out-of-order
# 5 distinct values chosen to increase the chance of different
# fragments (and therefore potentially different SUMA->Binlog
# orders) being seen.
#
insert into t1 values (1,1);
insert into t1 values (2,2);
insert into t1 values (3,3);
insert into t1 values (4,4);
insert into t1 values (5,5);

# Do a 'right shift' on the unique key values
update t1 set uk=uk-1 order by pk;

--echo Master table contents
select * from t1 order by pk;

--sleep 1

--connection slave

--echo Slave table contents
select * from t1 order by pk;

--source include/show_slave_status.inc

--connection master
drop table t1;