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

--sync_slave_with_master implicitly changes to slave without returning to master

Details

    Description

      --source include/master-slave.inc
      SET sql_mode='';
      CREATE TEMPORARY TABLE t (c INT);
      --sync_slave_with_master
      DROP TEMPORARY TABLE t;
      --source include/rpl_end.inc
      

      In MTR leads to:

      11.5.0 3f9182126c64bcec359bebe9ebad2a0e559b13e2 (Debug)

      include/master-slave.inc
      [connection master]
      SET sql_mode='';
      CREATE TEMPORARY TABLE t (c INT);
      connection slave;
      DROP TEMPORARY TABLE t;
      main.test3 'mix'                         [ fail ]
              Test ended at 2024-05-09 18:24:16
       
      CURRENT_TEST: main.test3
      mysqltest: At line 5: query 'DROP TEMPORARY TABLE t' failed: ER_BAD_TABLE_ERROR (1051): Unknown table 'test.t'
      

      The bug is not present if --sync_slave_with_master is removed:

      11.5.0 3f9182126c64bcec359bebe9ebad2a0e559b13e2 (Debug)

      include/master-slave.inc
      [connection master]
      SET sql_mode='';
      CREATE TEMPORARY TABLE t (c INT);
      DROP TEMPORARY TABLE t;
      include/rpl_end.inc
      main.test3 'mix'                         [ pass ]    991
      include/master-slave.inc
      [connection master]
      SET sql_mode='';
      CREATE TEMPORARY TABLE t (c INT);
      DROP TEMPORARY TABLE t;
      include/rpl_end.inc
      main.test3 'row'                         [ pass ]    938
      include/master-slave.inc
      [connection master]
      SET sql_mode='';
      CREATE TEMPORARY TABLE t (c INT);
      DROP TEMPORARY TABLE t;
      include/rpl_end.inc
      main.test3 'stmt'                        [ pass ]    966
      --------------------------------------------------------------------------
      The servers were restarted 2 times
      Spent 2.895 of 7 seconds executing testcases
       
      Completed: All 3 tests were successful.
      

      This results in some testing oddities. There may be other issues with --sync_slave_with_master.

      Attachments

        Issue Links

          Activity

            It's a quirk of --sync_slave_with_master, it implicitly does a --connection slave, switching to a different connection.
            So the DROP TEMPORARY TABLE is executed against the slave, where the table indeed does not exist.
            So just add a --connection master after the --sync_slave_with_master, and things should work.

            knielsen Kristian Nielsen added a comment - It's a quirk of --sync_slave_with_master, it implicitly does a --connection slave, switching to a different connection. So the DROP TEMPORARY TABLE is executed against the slave, where the table indeed does not exist. So just add a --connection master after the --sync_slave_with_master, and things should work.
            Roel Roel Van de Paar added a comment - - edited

            --source include/master-slave.inc
            SET sql_mode='';
            CREATE TEMPORARY TABLE t (c INT);
            --sync_slave_with_master
            --connection master
            DROP TEMPORARY TABLE t;
            --source include/rpl_end.inc
            

            Indeed works. Thank you for the workaround! Hopefully we can fix it in MTR too so it will automatically revert to the original connection and work as intended (sync with slave and return).

            Roel Roel Van de Paar added a comment - - edited --source include/master-slave.inc SET sql_mode= '' ; CREATE TEMPORARY TABLE t (c INT ); --sync_slave_with_master --connection master DROP TEMPORARY TABLE t; --source include/rpl_end.inc Indeed works. Thank you for the workaround! Hopefully we can fix it in MTR too so it will automatically revert to the original connection and work as intended (sync with slave and return).

            It already works as intended. It has always worked this way, in MariaDB as well as in MySQL, and is explicitly documented at least for MySQL.

            elenst Elena Stepanova added a comment - It already works as intended. It has always worked this way, in MariaDB as well as in MySQL, and is explicitly documented at least for MySQL.

            Ah, great, thank you for the documentation link. No point in changing it then. Thanks

            Roel Roel Van de Paar added a comment - Ah, great, thank you for the documentation link. No point in changing it then. Thanks

            People

              Elkin Andrei Elkin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.