#At file:///home/frazer/bzr/mysql-5.1-telco-6.2/
3020 Frazer Clement 2009-10-07
Bug#46662 : Ndb : mysqlbinlog fails to apply update to table with unique index
modified:
mysql-test/suite/ndb_binlog/r/ndb_binlog_variants.result
mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.test
sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_variants.result'
--- a/mysql-test/suite/ndb_binlog/r/ndb_binlog_variants.result 2009-10-07 16:26:17 +0000
+++ b/mysql-test/suite/ndb_binlog/r/ndb_binlog_variants.result 2009-10-07 16:27:03 +0000
@@ -75,3 +75,19 @@ ks st lp
3 3 3
4 4 40
drop table ba;
+reset master;
+show variables like '%log_update%';
+Variable_name Value
+sql_log_update ON
+create table bah (tst int primary key, cvy int, sqs int, unique(sqs)) engine=ndb;
+insert into bah values (1,1,1);
+update bah set cvy= 2 where tst=1;
+select * from bah order by tst;
+tst cvy sqs
+1 2 1
+drop table bah;
+Manually applying captured binlog
+select * from bah order by tst;
+tst cvy sqs
+1 2 1
+drop table bah;
=== modified file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.test'
--- a/mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.test 2009-10-07 16:26:17 +0000
+++ b/mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.test 2009-10-07 16:27:03 +0000
@@ -152,3 +152,64 @@ let $MYSQLD_DATADIR= `select @@datadir;`
select * from ba order by ks;
drop table ba;
+
+
+# Bug#46662
+# Replicating changes to tables with unique indexes
+# The fix to bug#27378 results in the slave using NdbApi's write()
+# mechanism when applying WRITE_ROW events to tables with unique
+# indices.
+#
+# If this is not done then the slave attempts to partially use SQL
+# REPLACE semantics when applying WRITE_ROW events to tables with
+# unique indexes, which is not good and the slave fails with a
+# duplicate key error on the primary key.
+#
+# The fix to Bug#46662 aims to correct this, so that replicated
+# updates to tables with unique indices can work.
+# Note that other issues with replicating into tables with unique
+# indexes remain.
+#
+
+connection mysqld1;
+reset master;
+show variables like '%log_update%';
+
+create table bah (tst int primary key, cvy int, sqs int, unique(sqs)) engine=ndb;
+
+insert into bah values (1,1,1);
+
+# Wait for epoch to complete in Binlog
+--disable_query_log
+create table dummy (a int primary key) engine=ndb;
+--enable_query_log
+
+# Now perform update
+# This will be logged as WRITE
+# Without ability to use NdbApi write() for replace, mysqlbinlog
+# application will fail with duplicate key error on insert.
+update bah set cvy= 2 where tst=1;
+
+select * from bah order by tst;
+
+# Wait for epoch to complete in Binlog
+--disable_query_log
+drop table dummy;
+flush logs;
+--enable_query_log
+
+drop table bah;
+
+# Now let's re-apply the binlog
+# Without fix, this fails with duplicate PK error
+--echo Manually applying captured binlog
+--disable_query_log
+let $MYSQLD_DATADIR= `select @@datadir;`;
+let $BINLOG_FILE= '$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql';
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/mysqld-bin.000001 > $BINLOG_FILE
+--exec $MYSQL -uroot < $BINLOG_FILE
+
+--enable_query_log
+select * from bah order by tst;
+
+drop table bah;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-10-07 16:26:17 +0000
+++ b/sql/ha_ndbcluster.cc 2009-10-07 16:27:03 +0000
@@ -4234,7 +4234,8 @@ int ha_ndbcluster::extra(enum ha_extra_f
case HA_EXTRA_WRITE_CAN_REPLACE:
DBUG_PRINT("info", ("HA_EXTRA_WRITE_CAN_REPLACE"));
if (!m_has_unique_index ||
- current_thd->slave_thread) /* always set if slave, quick fix for bug 27378 */
+ current_thd->slave_thread || /* always set if slave, quick fix for bug 27378 */
+ isManualBinlogExec(current_thd)) /* or if manual binlog application, for bug 46662 */
{
DBUG_PRINT("info", ("Turning ON use of write instead of insert"));
m_use_write= TRUE;
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (frazer:3020) Bug#46662 | Frazer Clement | 7 Oct |