Loading libmysql/Makefile.shared +2 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,8 @@ clean-local: `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \ $(CHARSET_SRCS) $(CHARSET_OBJS) \ $(mystringsextra) $(mysysheaders) $(vioheaders)\ ../linked_client_sources net.c ../linked_libmysql_sources ../linked_libmysql_r_sources \ net.c conf_to_src_SOURCES = conf_to_src.c conf_to_src_LDADD= Loading mysql-test/r/rpl_deadlock.result +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ create table t1 (a int not null, key(a)) engine=innodb; create table t2 (a int not null, key(a)) engine=innodb; create table t3 (a int) engine=innodb; create table t4 (a int) engine=innodb; show variables like 'slave_transaction_retries'; Variable_name Value slave_transaction_retries 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( Loading @@ -20,6 +23,9 @@ t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL, KEY `a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 show variables like 'slave_transaction_retries'; Variable_name Value slave_transaction_retries 2 stop slave; begin; insert into t3 select * from t2 for update; Loading mysql-test/t/rpl_deadlock.test +4 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ # (Guilhem) have seen the test manage to provoke lock wait timeout # error but not deadlock error; that is ok as code deals with the two # errors in exactly the same way. # We don't 'show status like 'slave_retried_transactions'' because this # is not repeatable (depends on sleeps). source include/have_innodb.inc; source include/master-slave.inc; Loading @@ -16,10 +18,12 @@ create table t1 (a int not null, key(a)) engine=innodb; create table t2 (a int not null, key(a)) engine=innodb; create table t3 (a int) engine=innodb; create table t4 (a int) engine=innodb; show variables like 'slave_transaction_retries'; sync_slave_with_master; show create table t1; show create table t2; show variables like 'slave_transaction_retries'; stop slave; # 1) Test deadlock Loading sql/mysqld.cc +13 −3 Original line number Diff line number Diff line Loading @@ -3134,8 +3134,17 @@ we force server id to 2, but this MySQL server will not act as a slave."); #endif if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ opt_skip_slave_start= 1; /* init_slave() must be called after the thread keys are created */ init_slave(); /* init_slave() must be called after the thread keys are created. Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other places) assume that active_mi != 0, so let's fail if it's 0 (out of memory); a message has already been printed. */ if (init_slave() && !active_mi) { end_thr_alarm(1); // Don't allow alarms unireg_abort(1); } if (opt_bootstrap) { Loading Loading @@ -5690,6 +5699,7 @@ struct show_var_st status_vars[]= { {"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS}, {"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG}, {"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING}, {"Slave_retried_transactions",(char*) 0, SHOW_SLAVE_RETRIED_TRANS}, {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG}, {"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS}, {"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS}, Loading sql/slave.cc +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <my_dir.h> #include <sql_common.h> #define MAX_SLAVE_RETRY_PAUSE 5 bool use_slave_mask = 0; MY_BITMAP slave_error_mask; Loading Loading @@ -2528,7 +2529,7 @@ st_relay_log_info::st_relay_log_info() ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE), until_log_pos(0) until_log_pos(0), retried_trans(0) { group_relay_log_name[0]= event_relay_log_name[0]= group_master_log_name[0]= 0; Loading Loading @@ -3261,9 +3262,8 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) init_master_info()). b) init_relay_log_pos(), because the BEGIN may be an older relay log. */ if (rli->trans_retries--) if (rli->trans_retries < slave_trans_retries) { sql_print_information("Slave SQL thread retries transaction"); if (init_master_info(rli->mi, 0, 0, 0, SLAVE_SQL)) sql_print_error("Failed to initialize the master info structure"); else if (init_relay_log_pos(rli, Loading @@ -3275,7 +3275,15 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) else { exec_res= 0; sleep(2); // chance for concurrent connection to get more locks /* 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); pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS rli->trans_retries++; rli->retried_trans++; pthread_mutex_unlock(&rli->data_lock); DBUG_PRINT("info", ("Slave retries transaction " "rli->trans_retries: %lu", rli->trans_retries)); } } else Loading @@ -3285,7 +3293,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) slave_trans_retries); } if (!((thd->options & OPTION_BEGIN) && opt_using_transactions)) rli->trans_retries= slave_trans_retries; // restart from fresh rli->trans_retries= 0; // restart from fresh } return exec_res; } Loading Loading @@ -3701,7 +3709,7 @@ extern "C" pthread_handler_decl(handle_slave_sql,arg) pthread_mutex_lock(&rli->log_space_lock); rli->ignore_log_space_limit= 0; pthread_mutex_unlock(&rli->log_space_lock); rli->trans_retries= slave_trans_retries; // start from "no error" rli->trans_retries= 0; // start from "no error" if (init_relay_log_pos(rli, rli->group_relay_log_name, Loading Loading
libmysql/Makefile.shared +2 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,8 @@ clean-local: `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \ $(CHARSET_SRCS) $(CHARSET_OBJS) \ $(mystringsextra) $(mysysheaders) $(vioheaders)\ ../linked_client_sources net.c ../linked_libmysql_sources ../linked_libmysql_r_sources \ net.c conf_to_src_SOURCES = conf_to_src.c conf_to_src_LDADD= Loading
mysql-test/r/rpl_deadlock.result +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ create table t1 (a int not null, key(a)) engine=innodb; create table t2 (a int not null, key(a)) engine=innodb; create table t3 (a int) engine=innodb; create table t4 (a int) engine=innodb; show variables like 'slave_transaction_retries'; Variable_name Value slave_transaction_retries 0 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( Loading @@ -20,6 +23,9 @@ t2 CREATE TABLE `t2` ( `a` int(11) NOT NULL, KEY `a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 show variables like 'slave_transaction_retries'; Variable_name Value slave_transaction_retries 2 stop slave; begin; insert into t3 select * from t2 for update; Loading
mysql-test/t/rpl_deadlock.test +4 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ # (Guilhem) have seen the test manage to provoke lock wait timeout # error but not deadlock error; that is ok as code deals with the two # errors in exactly the same way. # We don't 'show status like 'slave_retried_transactions'' because this # is not repeatable (depends on sleeps). source include/have_innodb.inc; source include/master-slave.inc; Loading @@ -16,10 +18,12 @@ create table t1 (a int not null, key(a)) engine=innodb; create table t2 (a int not null, key(a)) engine=innodb; create table t3 (a int) engine=innodb; create table t4 (a int) engine=innodb; show variables like 'slave_transaction_retries'; sync_slave_with_master; show create table t1; show create table t2; show variables like 'slave_transaction_retries'; stop slave; # 1) Test deadlock Loading
sql/mysqld.cc +13 −3 Original line number Diff line number Diff line Loading @@ -3134,8 +3134,17 @@ we force server id to 2, but this MySQL server will not act as a slave."); #endif if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ opt_skip_slave_start= 1; /* init_slave() must be called after the thread keys are created */ init_slave(); /* init_slave() must be called after the thread keys are created. Some parts of the code (e.g. SHOW STATUS LIKE 'slave_running' and other places) assume that active_mi != 0, so let's fail if it's 0 (out of memory); a message has already been printed. */ if (init_slave() && !active_mi) { end_thr_alarm(1); // Don't allow alarms unireg_abort(1); } if (opt_bootstrap) { Loading Loading @@ -5690,6 +5699,7 @@ struct show_var_st status_vars[]= { {"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS}, {"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG}, {"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING}, {"Slave_retried_transactions",(char*) 0, SHOW_SLAVE_RETRIED_TRANS}, {"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG}, {"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS}, {"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS}, Loading
sql/slave.cc +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include <my_dir.h> #include <sql_common.h> #define MAX_SLAVE_RETRY_PAUSE 5 bool use_slave_mask = 0; MY_BITMAP slave_error_mask; Loading Loading @@ -2528,7 +2529,7 @@ st_relay_log_info::st_relay_log_info() ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE), until_log_pos(0) until_log_pos(0), retried_trans(0) { group_relay_log_name[0]= event_relay_log_name[0]= group_master_log_name[0]= 0; Loading Loading @@ -3261,9 +3262,8 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) init_master_info()). b) init_relay_log_pos(), because the BEGIN may be an older relay log. */ if (rli->trans_retries--) if (rli->trans_retries < slave_trans_retries) { sql_print_information("Slave SQL thread retries transaction"); if (init_master_info(rli->mi, 0, 0, 0, SLAVE_SQL)) sql_print_error("Failed to initialize the master info structure"); else if (init_relay_log_pos(rli, Loading @@ -3275,7 +3275,15 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) else { exec_res= 0; sleep(2); // chance for concurrent connection to get more locks /* 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); pthread_mutex_lock(&rli->data_lock); // because of SHOW STATUS rli->trans_retries++; rli->retried_trans++; pthread_mutex_unlock(&rli->data_lock); DBUG_PRINT("info", ("Slave retries transaction " "rli->trans_retries: %lu", rli->trans_retries)); } } else Loading @@ -3285,7 +3293,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) slave_trans_retries); } if (!((thd->options & OPTION_BEGIN) && opt_using_transactions)) rli->trans_retries= slave_trans_retries; // restart from fresh rli->trans_retries= 0; // restart from fresh } return exec_res; } Loading Loading @@ -3701,7 +3709,7 @@ extern "C" pthread_handler_decl(handle_slave_sql,arg) pthread_mutex_lock(&rli->log_space_lock); rli->ignore_log_space_limit= 0; pthread_mutex_unlock(&rli->log_space_lock); rli->trans_retries= slave_trans_retries; // start from "no error" rli->trans_retries= 0; // start from "no error" if (init_relay_log_pos(rli, rli->group_relay_log_name, Loading