mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
BUG#51226: mysqlbinlog replay: ERROR 1146 when using temp tables
+ failing statements Implicit DROP event for temporary table is not getting LOG_EVENT_THREAD_SPECIFIC_F flag, because, in the previous executed statement in the same thread, which might even be a failed statement, the thread_specific_used flag is set to FALSE (in mysql_reset_thd_for_next_command) and not set to TRUE before connection is shutdown. This means that implicit DROP event will take the FALSE value from thread_specific_used and will not set LOG_EVENT_THREAD_SPECIFIC_F in the event header. As a consequence, mysqlbinlog will not print the pseudo_thread_id from the DROP event, because one of the requirements for the printout is that this flag is set to TRUE. We fix this by setting thread_specific_used whenever we are binlogging a DROP in close_temporary_tables, and resetting it to its previous value afterward.
This commit is contained in:
@ -82,3 +82,69 @@ select * from foo;
|
||||
|
||||
# clean up
|
||||
drop table foo;
|
||||
|
||||
#################################################################
|
||||
# BUG#51226
|
||||
#################################################################
|
||||
|
||||
RESET MASTER;
|
||||
|
||||
-- let $dbname=b51226
|
||||
|
||||
connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||
connect (con2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
||||
|
||||
#
|
||||
# action: on con1 create the database and the tmp table
|
||||
#
|
||||
-- connection con1
|
||||
-- eval create database $dbname
|
||||
-- eval use $dbname
|
||||
create temporary table t1(i int);
|
||||
|
||||
#
|
||||
# action: on con1 create the tmp table
|
||||
#
|
||||
-- connection con2
|
||||
-- eval use $dbname
|
||||
create temporary table t1(i int);
|
||||
|
||||
# action: at this point, the last event binlogged contains the
|
||||
# pseudo_thread_id from con2. So now we switch to con1, issue
|
||||
# a statement that fails and close the connection (which logs
|
||||
# implicitely a DROP TEMPORARY TABLE).
|
||||
#
|
||||
# Before the patch this would not log con1's pseudo_thread_id
|
||||
# because the failing statement would reset THD context
|
||||
# (unsetting the thread_specific_used flag, and consequently,
|
||||
# causing the DROP event to be logged without pseudo_thread_id
|
||||
# in its header).
|
||||
|
||||
-- connection con1
|
||||
-- error 1050
|
||||
create temporary table t1(i int);
|
||||
-- disconnect con1
|
||||
|
||||
-- connection default
|
||||
-- let $wait_binlog_event= DROP
|
||||
-- source include/wait_for_binlog_event.inc
|
||||
|
||||
# action: insert in the t1. This would cause the the test to fail,
|
||||
# because when replaying the binlog the previous implicit drop
|
||||
# temp table would have been executed under the wrong
|
||||
# pseudo_thread_id, dropping the tmp table on con2.
|
||||
-- connection con2
|
||||
insert into t1 values(1);
|
||||
-- disconnect con2
|
||||
|
||||
-- connection default
|
||||
-- let $wait_binlog_event= DROP
|
||||
-- source include/wait_for_binlog_event.inc
|
||||
|
||||
-- eval DROP DATABASE $dbname
|
||||
FLUSH LOGS;
|
||||
|
||||
# assertion: assert that when replaying the binary log will succeed,
|
||||
# instead of failing with "Table 'XXX.YYY' doesn't exist"
|
||||
-- let $MYSQLD_DATADIR= `select @@datadir`
|
||||
-- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
|
||||
|
Reference in New Issue
Block a user