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

DROP TEMPORARY TABLE creates a transaction in binary log on read only server

    XMLWordPrintable

Details

    Description

      If "DROP TEMPORARY TABLE..." gets executed on server with GTID enabled and read_only mode enabled, then 'DROP /* TEMPORARY */ TABLE IF EXISTS `sometablename`' gets inserted in server binary log. This creates errant extra transaction on slave and breaks replication.
      As temporary tables are never replicated with RBR format so might be good to disable binlogging of temporary tables.

      mysql [localhost] {msandbox} (test) > SHOW CREATE PROCEDURE testproc\G
      *************************** 1. row ***************************
                 Procedure: testproc
                  sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
          Create Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `testproc`()
      BEGIN
         DROP TEMPORARY TABLE IF EXISTS `t1_tmp`;
         DROP TEMPORARY TABLE IF EXISTS `t2_tmp`;
         
         CREATE TEMPORARY TABLE IF NOT EXISTS `t1_tmp` (
         `t1` varchar(400) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
       
      CREATE TEMPORARY TABLE IF NOT EXISTS `t2_tmp` (
        `t2` varchar(16) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
      END
      character_set_client: latin1
      collation_connection: latin1_swedish_ci
        Database Collation: latin1_swedish_ci
      1 row in set (0.00 sec)
       
      mysql [localhost] {msandbox} ((none)) > USE test;
      Database changed
      mysql [localhost] {msandbox} (test) > SET GLOBAL read_only=1;
      Query OK, 0 rows affected (0.00 sec)
       
      mysql [localhost] {msandbox} (test) > CALL testproc();
      Query OK, 0 rows affected (0.02 sec)
       
       
      mysql [localhost] {msandbox} (test) > SHOW BINLOG EVENTS;
       
      +------+-------------+-----------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Log_name         | Pos  | Event_type  | Server_id | End_log_pos | Info                                                                                                                                                                                                                                                                                                                                                                                                                                         |
      +------------------+------+-------------+-----------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
       
      | mysql-bin.000001 | 1167 | Query       |         1 |        1306 | use `test`; DROP TEMPORARY TABLE IF EXISTS `t1_tmp` /* generated by server */                                                                                                                                                                                                                                                                                                                                                                |
      | mysql-bin.000001 | 1306 | Query       |         1 |        1445 | use `test`; DROP TEMPORARY TABLE IF EXISTS `t2_tmp` /* generated by server */                                                                                                                                                                                                                                                                                                                                                                |
      | mysql-bin.000001 | 1445 | Query       |         1 |        1648 | use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t1_tmp` (
         `t1` varchar(400) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8                                                                                                                                                                                                                                                                                                |
      | mysql-bin.000001 | 1648 | Query       |         1 |        1843 | use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t2_tmp` (
        `t2` varchar(16) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8            
      +------------------+------+-------------+-----------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+  
      

      Upstream https://bugs.mysql.com/bug.php?id=85258

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              muhammad.irfan Muhammad Irfan
              Votes:
              1 Vote for this issue
              Watchers:
              7 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.