diff options
author | Luis Soares <luis.soares@sun.com> | 2009-05-23 00:15:21 +0100 |
---|---|---|
committer | Luis Soares <luis.soares@sun.com> | 2009-05-23 00:15:21 +0100 |
commit | 8e589d1d06d48471bcef7164e458f6d9cefec2ec (patch) | |
tree | 44567e30c04a8f89af2c6f7ee07fabe108510146 /sql/slave.cc | |
parent | a41d2dafa0759a010ba6c8c1115852be3dd247a8 (diff) | |
download | mariadb-git-8e589d1d06d48471bcef7164e458f6d9cefec2ec.tar.gz |
BUG#41725: slave crashes when inserting into temporary table after
stop/start slave
When stopping and restarting the slave while it is replicating
temporary tables, the server would crash or raise an assertion
failure. This was due to the fact that although temporary tables are
saved between slave threads restart, the reference to the thread in
use (table->in_use) was not being properly updated when the restart
happened (it would still reference the old/invalid thread instead of
the new one).
This patch addresses this issue by resetting the reference to the new
slave thread on slave thread restart.
mysql-test/r/rpl_temporary.result:
Result file.
mysql-test/t/rpl_temporary.test:
Test case that checks that both failures go away.
sql/slave.cc:
Changed slave.cc to reset sql_thd reference in temporary tables.
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index f29936c5942..88c19a04602 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -545,6 +545,14 @@ void st_relay_log_info::close_temporary_tables() slave_open_temp_tables= 0; } +static void set_thd_in_use_temporary_tables(RELAY_LOG_INFO *rli) +{ + TABLE *table; + + for (table= rli->save_temporary_tables ; table ; table= table->next) + table->in_use= rli->sql_thd; +} + /* purge_relay_logs() @@ -3964,6 +3972,7 @@ slave_begin: } thd->init_for_queries(); thd->temporary_tables = rli->save_temporary_tables; // restore temp tables + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); @@ -4136,6 +4145,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ DBUG_ASSERT(rli->sql_thd == thd); THD_CHECK_SENTRY(thd); rli->sql_thd= 0; + set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables pthread_mutex_lock(&LOCK_thread_count); THD_CHECK_SENTRY(thd); delete thd; |