diff options
author | unknown <tomas@poseidon.mysql.com> | 2007-06-27 22:33:03 +0200 |
---|---|---|
committer | unknown <tomas@poseidon.mysql.com> | 2007-06-27 22:33:03 +0200 |
commit | 546997818549053d5ffe605735e1ca8054892d14 (patch) | |
tree | 9a76fda7f80997e537844f1cf8d8e626b4c59367 | |
parent | a290e0b362dc79fe02d00dc2e492e9f01e9ec464 (diff) | |
download | mariadb-git-546997818549053d5ffe605735e1ca8054892d14.tar.gz |
Bug #29222 Statement mode replicates both statement and rows when writing to an NDB table
- only log statements locally (changes will not be logged on other servers)
mysql-test/r/ndb_binlog_format.result:
New BitKeeper file ``mysql-test/r/ndb_binlog_format.result''
mysql-test/t/ndb_binlog_format.test:
New BitKeeper file ``mysql-test/t/ndb_binlog_format.test''
-rw-r--r-- | mysql-test/r/ndb_binlog_format.result | 30 | ||||
-rw-r--r-- | mysql-test/t/ndb_binlog_format.test | 32 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 30 | ||||
-rw-r--r-- | sql/ha_ndbcluster.h | 1 |
4 files changed, 85 insertions, 8 deletions
diff --git a/mysql-test/r/ndb_binlog_format.result b/mysql-test/r/ndb_binlog_format.result new file mode 100644 index 00000000000..ed26060e2a4 --- /dev/null +++ b/mysql-test/r/ndb_binlog_format.result @@ -0,0 +1,30 @@ +drop table if exists t1, t2, t3; +CREATE TABLE t1 (m INT, n INT) ENGINE=MYISAM; +CREATE TABLE t2 (b INT, c INT) ENGINE=BLACKHOLE; +CREATE TABLE t3 (e INT, f INT) ENGINE=NDB; +RESET MASTER; +SET SESSION BINLOG_FORMAT=STATEMENT; +INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2); +INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c; +START TRANSACTION; +INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f; +UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c; +COMMIT; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # use `test`; INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2) +master-bin.000001 # Query # # use `test`; UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f +master-bin.000001 # Query # # use `test`; UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c +master-bin.000001 # Query # # use `test`; COMMIT +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Table_map # # table_id: # (test.t3) +master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/ndb_binlog_format.test b/mysql-test/t/ndb_binlog_format.test new file mode 100644 index 00000000000..76cf4b40bb2 --- /dev/null +++ b/mysql-test/t/ndb_binlog_format.test @@ -0,0 +1,32 @@ +# +# test different behavior of ndb using different binlog formats +# + +-- source include/have_ndb.inc +-- source include/have_log_bin.inc + +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings + +# +# Bug #29222 Statement mode replicates both statement and +# rows when writing to an NDB table +# +CREATE TABLE t1 (m INT, n INT) ENGINE=MYISAM; +CREATE TABLE t2 (b INT, c INT) ENGINE=BLACKHOLE; +CREATE TABLE t3 (e INT, f INT) ENGINE=NDB; +RESET MASTER; +SET SESSION BINLOG_FORMAT=STATEMENT; +INSERT INTO t1 VALUES (1,1), (1,2), (2,1), (2,2); +INSERT INTO t2 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t2 SET m = 2, b = 3 WHERE n = c; +# A transaction here is not necessary, but I wanted to group the bad statements +START TRANSACTION; +INSERT INTO t3 VALUES (1,1), (1,2), (2,1), (2,2); +UPDATE t1, t3 SET m = 2, e = 3 WHERE n = f; +UPDATE t3, t2 SET e = 2, b = 3 WHERE f = c; +COMMIT; +--source include/show_binlog_events.inc +DROP TABLE t1, t2, t3; + diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 102c21d19a0..2b34eff8479 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2812,7 +2812,8 @@ int ha_ndbcluster::write_row(uchar *record) if (unlikely(m_slow_path)) { - if (!(thd->options & OPTION_BIN_LOG)) + Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (thd_ndb->trans_options & TNTO_NO_LOGGING) op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING); else if (thd->slave_thread) op->setAnyValue(thd->server_id); @@ -3101,7 +3102,8 @@ int ha_ndbcluster::update_row(const uchar *old_data, uchar *new_data) if (unlikely(m_slow_path)) { - if (!(thd->options & OPTION_BIN_LOG)) + Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (thd_ndb->trans_options & TNTO_NO_LOGGING) op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING); else if (thd->slave_thread) op->setAnyValue(thd->server_id); @@ -3168,7 +3170,8 @@ int ha_ndbcluster::delete_row(const uchar *record) if (unlikely(m_slow_path)) { - if (!(thd->options & OPTION_BIN_LOG)) + Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (thd_ndb->trans_options & TNTO_NO_LOGGING) ((NdbOperation *)trans->getLastDefinedOperation())-> setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING); else if (thd->slave_thread) @@ -3207,7 +3210,8 @@ int ha_ndbcluster::delete_row(const uchar *record) if (unlikely(m_slow_path)) { - if (!(thd->options & OPTION_BIN_LOG)) + Thd_ndb *thd_ndb= get_thd_ndb(thd); + if (thd_ndb->trans_options & TNTO_NO_LOGGING) op->setAnyValue(NDB_ANYVALUE_FOR_NOLOGGING); else if (thd->slave_thread) op->setAnyValue(thd->server_id); @@ -4385,8 +4389,13 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) thd_ndb->query_state&= NDB_QUERY_NORMAL; thd_ndb->trans_options= 0; thd_ndb->m_slow_path= FALSE; - if (thd->slave_thread || - !(thd->options & OPTION_BIN_LOG)) + if (!(thd->options & OPTION_BIN_LOG) || + thd->variables.binlog_format == BINLOG_FORMAT_STMT) + { + thd_ndb->trans_options|= TNTO_NO_LOGGING; + thd_ndb->m_slow_path= TRUE; + } + else if (thd->slave_thread) thd_ndb->m_slow_path= TRUE; trans_register_ha(thd, FALSE, ndbcluster_hton); } @@ -4406,8 +4415,13 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) thd_ndb->query_state&= NDB_QUERY_NORMAL; thd_ndb->trans_options= 0; thd_ndb->m_slow_path= FALSE; - if (thd->slave_thread || - !(thd->options & OPTION_BIN_LOG)) + if (!(thd->options & OPTION_BIN_LOG) || + thd->variables.binlog_format == BINLOG_FORMAT_STMT) + { + thd_ndb->trans_options|= TNTO_NO_LOGGING; + thd_ndb->m_slow_path= TRUE; + } + else if (thd->slave_thread) thd_ndb->m_slow_path= TRUE; trans_register_ha(thd, TRUE, ndbcluster_hton); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 5c6646f68af..4f5a1359d2d 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -178,6 +178,7 @@ enum THD_NDB_OPTIONS enum THD_NDB_TRANS_OPTIONS { TNTO_INJECTED_APPLY_STATUS= 1 << 0 + ,TNTO_NO_LOGGING= 1 << 1 }; struct Ndb_local_table_statistics { |