Commit 6bc324ed authored by unknown's avatar unknown
Browse files

"After Monty's review" changes to the fix for BUG#8325 "Deadlock in...

"After Monty's review" changes to the fix for BUG#8325 "Deadlock in replication thread stops replication":
s/sleep/safe_sleep (thread safe); sleep 0/1/2/3/4/5/5/5 (get slave less late);
no message on error log (deadlock is too common sometimes), a global counter
instead (SHOW STATUS LIKE 'slave_retried_transactions').
Plus a fix for libmysql/Makefile.shared


libmysql/Makefile.shared:
  When we "make clean" in libmysql/ we remove the symlinks there, so we
  need to mark that they have to be recreated later: this is done by removing
  ../linked_libmysql_sources. If we don't do this, 'make' will fail after 'cd libmysql;make clean'.
  This Makefile.shared is used by libmysql_r too.
  No reason to remove linked_client_sources as we don't remove the links in client/.
mysql-test/r/rpl_deadlock.result:
  result fix
mysql-test/t/rpl_deadlock.test:
  small test addition
sql/mysqld.cc:
  if active_mi could not be alloced, die. New SHOW STATUS LIKE "slave_retried_transactions".
sql/slave.cc:
  If slave retries automatically a transaction, no message on error log
  (too common situation); sleep 0 secs at first retry, then 1, 2, 3, 4,
  5, 5, 5... Sleeping 0 is to get the least possible late, as deadlocks
  are usually resolved at first try. New global counter rli->retried_trans
  (for SHOW STATUS: total number of times the slave had to retry
  any transaction). safe_sleep() is thread-safe, sleep() was not.
  I change the rli->trans_retries counter to go from 0 to max instead
  of the other way (better for new sleep()).
sql/slave.h:
  new global counter rli->retried_trans
sql/sql_show.cc:
  SHOW STATUS LIKE "slave_retried_transactions"; needs replication mutexes.
  Can't be a simple SHOW_LONG, because active_mi is unset (not alloced yet)
  when the static global status_vars is created (active_mi is set
  in init_slave()).
sql/structs.h:
  new SHOW_SLAVE_RETRIED_TRANS
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 3a88de43
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ dlenev@build.mysql.com
dlenev@jabberwock.localdomain
dlenev@mysql.com
ejonore@mc03.ndb.mysql.com
gbichot@quadita2.mysql.com
gbichot@quadxeon.mysql.com
georg@beethoven.local
georg@lmy002.wdf.sap.corp
+2 −1
Original line number Diff line number Diff line
@@ -94,7 +94,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=
+6 −0
Original line number Diff line number Diff line
@@ -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` (
@@ -20,6 +23,9 @@ t2 CREATE TABLE `t2` (
  `a` int(11) NOT NULL default '0',
  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;
+4 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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
+13 −3
Original line number Diff line number Diff line
@@ -3062,8 +3062,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)
  {
@@ -5495,6 +5504,7 @@ struct show_var_st status_vars[]= {
  {"Select_scan",	       (char*) &select_scan_count,	SHOW_LONG},
  {"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*) &long_query_count,       SHOW_LONG},
  {"Sort_merge_passes",	       (char*) &filesort_merge_passes,  SHOW_LONG},
Loading