diff --git a/mysql-test/r/rpl_ndb_basic.result b/mysql-test/r/rpl_ndb_basic.result index 0fe681622c9..40e3384be3b 100644 --- a/mysql-test/r/rpl_ndb_basic.result +++ b/mysql-test/r/rpl_ndb_basic.result @@ -71,13 +71,47 @@ CREATE TABLE `t1` ( `nid` int(11) NOT NULL default '0', PRIMARY KEY USING HASH (`nid`)) ENGINE=ndbcluster DEFAULT CHARSET=latin1; INSERT INTO t1 VALUES(1,"XYZ1","ABC1"); +**** On Slave **** BEGIN; UPDATE t1 SET `nom`="LOCK" WHERE `nid`=1; set GLOBAL slave_transaction_retries=1; +**** On Master **** UPDATE t1 SET `nom`="DEAD" WHERE `nid`=1; -SHOW SLAVE STATUS; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master - 127.0.0.1 root MASTER_PORT 1 master-bin.000001 master-bin.000001 Yes No 146 Error in Write_rows event: error during transaction execution on table test.t1 0 None 0 No +**** On Slave **** +SHOW SLAVE STATUS;; +Slave_IO_State +Master_Host 127.0.0.1 +Master_User root +Master_Port MASTER_PORT +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos +Relay_Log_File +Relay_Log_Pos +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 146 +Last_Error Error in Write_rows event: error during transaction execution on table test.t1 +Skip_Counter 0 +Exec_Master_Log_Pos +Relay_Log_Space +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master set GLOBAL slave_transaction_retries=10; START SLAVE; select * from t1 order by nid; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index c32750d89e4..0954e2a1732 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -25,7 +25,7 @@ rpl_ddl : Bug#15963 SBR does not show "Definer" correctly rpl_ndb_2innodb : Bugs#17400: delete & update of rows in table without pk fails rpl_ndb_2myisam : Bugs#17400: delete & update of rows in table without pk fails rpl_ndb_auto_inc : Bug#17086 -rpl_ndb_basic : Bug#16228 [IN REVIEW] +#rpl_ndb_basic : Bug#16228 [IN REVIEW] rpl_ndb_charset : Bug#17246 rpl_ndb_ddl : Bug#17400: delete & update of rows in table without pk fails rpl_ndb_delete_nowhere : Bug#17400: delete & update of rows in table without pk fails diff --git a/mysql-test/t/rpl_ndb_basic.test b/mysql-test/t/rpl_ndb_basic.test index 57028464179..bcce0284642 100644 --- a/mysql-test/t/rpl_ndb_basic.test +++ b/mysql-test/t/rpl_ndb_basic.test @@ -98,6 +98,7 @@ INSERT INTO t1 VALUES(1,"XYZ1","ABC1"); # cause a lock on that row on the slave --sync_slave_with_master --connection slave +--echo **** On Slave **** BEGIN; UPDATE t1 SET `nom`="LOCK" WHERE `nid`=1; @@ -107,6 +108,7 @@ set GLOBAL slave_transaction_retries=1; # now do a change to this row on the master # will deadlock on the slave because of lock above --connection master +--echo **** On Master **** UPDATE t1 SET `nom`="DEAD" WHERE `nid`=1; # wait for deadlock to be detected @@ -119,14 +121,14 @@ UPDATE t1 SET `nom`="DEAD" WHERE `nid`=1; # replication should have stopped, since max retries where not enough # verify with show slave status --connection slave +--echo **** On Slave **** --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 7 8 9 16 22 23 33 -SHOW SLAVE STATUS; +--query_vertical SHOW SLAVE STATUS; # now set max retries high enough to succeed, and start slave again set GLOBAL slave_transaction_retries=10; START SLAVE; - # wait for deadlock to be detected and retried # should be the same sleep as above for test to be valid --sleep 5 diff --git a/sql/slave.cc b/sql/slave.cc index 39656700e1c..68c4757b735 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3093,6 +3093,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) else { exec_res= 0; + end_trans(thd, ROLLBACK); /* chance for concurrent connection to get more locks */ safe_sleep(thd, min(rli->trans_retries, MAX_SLAVE_RETRY_PAUSE), (CHECK_KILLED_FUNC)sql_slave_killed, (void*)rli); @@ -3110,8 +3111,16 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) "the slave_transaction_retries variable.", slave_trans_retries); } - if (!((thd->options & OPTION_BEGIN) && opt_using_transactions)) - rli->trans_retries= 0; // restart from fresh + else if (!((thd->options & OPTION_BEGIN) && opt_using_transactions)) + { + /* + Only reset the retry counter if the event succeeded or + failed with a non-transient error. On a successful event, + the execution will proceed as usual; in the case of a + non-transient error, the slave will stop with an error. + */ + rli->trans_retries= 0; // restart from fresh + } } return exec_res; }