diff options
author | unknown <aelkin/elkin@dsl-hkigw8-feb9fb00-191.dhcp.inet.fi> | 2006-10-11 10:16:37 +0300 |
---|---|---|
committer | unknown <aelkin/elkin@dsl-hkigw8-feb9fb00-191.dhcp.inet.fi> | 2006-10-11 10:16:37 +0300 |
commit | d6bc2d60e5a658d4f1e646f4f94664d815de683e (patch) | |
tree | 724c9295b4c768bb141d1bfffef26a420d873086 /sql/slave.cc | |
parent | c317c2d224c8d7753cf7acd238968a9a8584dbc4 (diff) | |
download | mariadb-git-d6bc2d60e5a658d4f1e646f4f94664d815de683e.tar.gz |
BUG#20697 slave fails to rollback replicated transaction hang over innodb_lock_wait_timeou
Transaction on the slave sql thread got blocked against a slave's mysqld local ta's
lock. Since the default, slave-transaction-retries=10, there was replaying of the
replicated ta. That failed because of a new started from 5.0.13 policy not to rollback
a timed-out transaction. Effectively the first round of a timed-out ta becomes committed
by the replaying's first "BEGIN".
It was decided to backport already existed method working in 5.1 implemented in
bug #16228 for handling symmetrical deadlock problem. That patch introduced end_trans
execution whenever a replicated ta deadlocks or timed-out.
Note, that this solution can be practically suboptimal - in the light of the changed behavior
due to timeout we still could replay only the last statement - only with a high rate of timeouting
replicated transactions.
mysql-test/r/rpl_deadlock.result:
results changed
mysql-test/t/rpl_deadlock.test:
Refining the timeout part of the test to display that the timed-out transaction
is rolled back prior its replaying by slave sql.
Non-zero select's count would mean the first round work became persistent - wrong.
sql/slave.cc:
applying bug#16228 fix, approbated for deadlock use case in 5.1, almost verbatim.
Another alternative to replay only the offending statement requires significant
efforts, incl design work.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 55cff94a179..244c5dfbcc4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3345,9 +3345,9 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) const char *errmsg; /* We were in a transaction which has been rolled back because of a - deadlock (currently, InnoDB deadlock detected by InnoDB) or lock - wait timeout (innodb_lock_wait_timeout exceeded); let's seek back to - BEGIN log event and retry it all again. + Sonera deadlock. if lock wait timeout (innodb_lock_wait_timeout exceeded) + there is no rollback since 5.0.13 (ref: manual). + let's seek back to BEGIN log event and retry it all again. We have to not only seek but also a) init_master_info(), to seek back to hot relay log's start for later (for when we will come back to this hot log after re-processing the @@ -3369,6 +3369,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); @@ -3386,9 +3387,17 @@ 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; } else @@ -4613,7 +4622,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi, suppress_warnings= 0; sql_print_error("Slave I/O thread: error %s to master \ '%s@%s:%d': \ -Error: '%s' errno: %d retry-time: %d retries: %d", +Error: '%s' errno: %d retry-time: %d retries: %lu", (reconnect ? "reconnecting" : "connecting"), mi->user,mi->host,mi->port, mysql_error(mysql), last_errno, |