Commit 812fa8b2 authored by mats@mats-laptop.(none)'s avatar mats@mats-laptop.(none)
Browse files

BUG#36197: flush tables (or little table cache) can cause crash on slave

When flushing tables, there were a slight chance that the flush was occuring
between processing of two table map events. Since the tables are opened
one by one, it might result in that the tables were not valid and that sub-
sequent locking of tables would cause the slave to crash.

The problem is solved by opening and locking all tables at once using
simple_open_n_lock_tables(). Also, the patch contain a change to open_tables()
so that pre-locking only takes place when the trg_event_map is not zero, which
was not the case before (this caused the lock to be placed in thd->locked_tables
instead of thd->lock since the assumption was that triggers would be called
later and therefore the tables should be pre-locked).
parent 2d7104e0
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
###################################################
#Author:  Mats (based on file written by Jeb)
#Date:    2008-05-06
#Purpose: To wait for slave SQL thread to start
#Details:
#      1) Fill in and setup variables
#      2) loop through looking for both
#         io and sql threads to start
#      3) If loops too long die.
####################################################
connection slave;
let $row_number= 1;
let $run= 1;
let $counter= 300;

while ($run)
{
  let $sql_result= query_get_value("SHOW SLAVE STATUS",  Slave_SQL_Running, $row_number);
  if (`SELECT '$sql_result' = 'Yes'`){
    let $run= 0;
  }
  sleep 0.1;
  if (!$counter){
    --echo "Failed while waiting for slave SQL to start"
    query_vertical SHOW SLAVE STATUS;
    exit;
  }
  dec $counter;
}

+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ sect test count
2	6	0
2	6	183
2	7	0
DROP TABLE t1, logtbl;
DROP TABLE t1, t2, logtbl;
DROP PROCEDURE just_log;
DROP PROCEDURE log_me;
DROP PROCEDURE log_me_inner;
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ Replicate_Ignore_Table #
Replicate_Wild_Do_Table	
Replicate_Wild_Ignore_Table	
Last_Errno	1146
Last_Error	Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1`
Last_Error	Error 'Table 'test.t1' doesn't exist' on opening tables
Skip_Counter	0
Exec_Master_Log_Pos	941
Relay_Log_Space	#
@@ -55,5 +55,5 @@ Master_SSL_Verify_Server_Cert No
Last_IO_Errno	#
Last_IO_Error	#
Last_SQL_Errno	1146
Last_SQL_Error	Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1`
Last_SQL_Error	Error 'Table 'test.t1' doesn't exist' on opening tables
drop table t1, t2;
+1 −1
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ sync_slave_with_master;
SELECT * FROM logtbl WHERE sect = 2 ORDER BY sect,test;

connection master;
DROP TABLE t1, logtbl;
DROP TABLE t1, t2, logtbl;
DROP PROCEDURE just_log;
DROP PROCEDURE log_me;
DROP PROCEDURE log_me_inner;
+3 −2
Original line number Diff line number Diff line
@@ -36,15 +36,16 @@ connection slave;
# 4. Restart slave without privileges
# (slave.err will contain access denied error for this START SLAVE command)
stop slave;
source include/wait_for_slave_to_stop.inc;
start slave;
source include/wait_for_slave_sql_to_start.inc;

# 5. Make sure Slave_IO_Running = No
--replace_result $MASTER_MYPORT MASTER_MYPORT
# Column 1 is replaced, since the output can be either
# "Connecting to master" or "Waiting for master update"
--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 35 # 36 #
--vertical_results
show slave status;
query_vertical show slave status;

# Cleanup (Note that slave IO thread is not running)
connection slave;
Loading