diff options
author | <Li-Bing.Song@sun.com> | 2010-10-16 20:03:44 +0800 |
---|---|---|
committer | <Li-Bing.Song@sun.com> | 2010-10-16 20:03:44 +0800 |
commit | 131e3e38fd301ae9beee898eacfd8d72f7983200 (patch) | |
tree | b80bfb21f72caa6f3993cf3e8c3af746eff108ad /sql/slave.cc | |
parent | 5f31581fffa451fad8bea05eaa37c06a3d81f924 (diff) | |
download | mariadb-git-131e3e38fd301ae9beee898eacfd8d72f7983200.tar.gz |
Bug#56118 STOP SLAVE does not wait till trx with CREATE TMP TABLE ends,
replication aborts
When recieving a 'SLAVE STOP' command, slave SQL thread will roll back the
transaction and stop immidiately if there is only transactional table updated,
even through 'CREATE|DROP TEMPOARY TABLE' statement are in it. But These
statements can never be rolled back. Because the temporary tables to the user
session mapping remain until 'RESET SLAVE', Therefore it will abort SQL thread
with an error that the table already exists or doesn't exist, when it restarts
and executes the whole transaction again.
After this patch, SQL thread always waits till the transaction ends and then stops,
if 'CREATE|DROP TEMPOARY TABLE' statement are in it.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 964adfdbf53..57d673ea1f4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -740,8 +740,17 @@ static bool sql_slave_killed(THD* thd, Relay_log_info* rli) DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun if (abort_loop || thd->killed || rli->abort_slave) { + /* + The transaction should always be binlogged if OPTION_KEEP_LOG is set + (it implies that something can not be rolled back). And such case + should be regarded similarly as modifing a non-transactional table + because retrying of the transaction will lead to an error or inconsistency + as well. + Example: OPTION_KEEP_LOG is set if a temporary table is created or dropped. + */ if (rli->abort_slave && rli->is_in_group() && - thd->transaction.all.modified_non_trans_table) + (thd->transaction.all.modified_non_trans_table || + (thd->options & OPTION_KEEP_LOG))) DBUG_RETURN(0); /* If we are in an unsafe situation (stopping could corrupt replication), |