Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-6403

Temporary tables lost at STOP SLAVE in GTID mode if master has not rotated binlog since restart

    XMLWordPrintable

Details

    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

      Attachments

        Activity

          People

            knielsen Kristian Nielsen
            knielsen Kristian Nielsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.