[MDEV-6403] Temporary tables lost at STOP SLAVE in GTID mode if master has not rotated binlog since restart Created: 2014-06-27  Updated: 2017-02-19  Resolved: 2015-03-04

Status: Closed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.0.12
Fix Version/s: 10.0.18, 10.1.4

Type: Bug Priority: Critical
Reporter: Kristian Nielsen Assignee: Kristian Nielsen
Resolution: Fixed Votes: 0
Labels: gtid, replication


 Description   

When the slave executes the first Format_description event that the master
logged just after a master restart, the slave deletes all active temporary
tables. The logic is that in case of master crash before the restart, those
temporary tables would have been silently discarded on the master but still
present on the slave, so the delete on the slave is needed to not accumulate
garbage temporary tables over time.

But this causes an error in GTID mode. In GTID mode, when slave connects, the
master scans its binlog from the start looking for the GTID position to start
at, and during the scan, it sends any Format_description event it encounters
to the slave.

Thus, if the slave threads stop in the middle of some updates using temporary
tables, then are restarted, the slave will again receive the
Format_description event at the start of the current binlog on the master. If
the master has not done a binlog rotate yet since restart, that execution will
kill all temporary tables on the slave, causing subsequent events using those
temporary tables to fail.

Test case:

--source include/master-slave.inc
 
--connection master
CREATE TABLE t1 (a INT PRIMARY KEY);
--sync_slave_with_master
 
--connection slave
--source include/stop_slave.inc
SET sql_log_bin= 0;
INSERT INTO t1 VALUES (1);
SET sql_log_bin= 1;
CHANGE MASTER TO master_use_gtid= current_pos;
 
--connection master
 
CREATE TEMPORARY TABLE t2 LIKE t1;
INSERT INTO t2 VALUE (1);
INSERT INTO t1 SELECT * FROM t2;
DROP TEMPORARY TABLE t2;
--save_master_pos
 
--connection slave
START SLAVE;
--let $slave_sql_errno=1062
--source include/wait_for_slave_sql_error.inc
 
STOP SLAVE IO_THREAD;
 
SET sql_log_bin= 0;
DELETE FROM t1 WHERE a=1;
SET sql_log_bin= 1;
 
--source include/start_slave.inc
--sync_with_master
SELECT * FROM t1 ORDER BY a;
 
--connection master
DROP TABLE t1;
 
--source include/rpl_end.inc



 Comments   
Comment by Kristian Nielsen [ 2015-03-04 ]

http://lists.askmonty.org/pipermail/commits/2015-March/007512.html

Generated at Thu Feb 08 07:11:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.