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

Erroneous CREATE OR REPLACE can cause replication abort

    XMLWordPrintable

Details

    Description

      Note:
      The problem here is that CREATE OR REPLACE TABLE causes an error on the master, because 10.4 does not support the feature implied by the statement, but it is still written to the binary log (with error_code=1492). On a slave of a higher version this statement will be executed successfully which expectedly causes replication abort

      Last_SQL_Error: Query caused different errors on master and slave.     Error on master: message (format)='For %-.64s partitions each partition must be defined' error code=1492 ; Error on slave: actual message='no error', error code=0. Default database: 'test'. Query: 'CREATE OR REPLACE TABLE t (a INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 1000'
      

      It doesn't happen with just any CREATE OR REPLACE error, so I think it is related to CREATE OR REPLACE still being non-atomic (MDEV-25292), that is, it is written in the binary log with an error code when the old table gets dropped, but the new one cannot be created.

      From the bug I filed long time ago (MDEV-8062) it appears that it worked differently back then – instead of CREATE OR REPLACE, DROP TABLE was written into the binary log, not that it was doing much good either.

      I've set affected versions to "10.4", because the test case below applies to 10.4 (the feature is supported in 10.5+). However it is just an example, the problem is probably generic, that's why "fix versions" are set to 10.5+. If however it is not so, and there are no use cases for 10.5+, it should be closed as "won't fix" because 10.4 goes EOL and such things shouldn't be touched there anymore.

      --source include/have_partition.inc
      --source include/have_log_bin.inc
       
      CREATE TABLE t (a INT);
      --error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
      CREATE OR REPLACE TABLE t (a INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 1000;
      SHOW BINLOG EVENTS;
       
      # Cleanup
      DROP TABLE IF EXISTS t;
      

      10.4 8e337e016ff882862d4d2f32488b5142370ff8da

      #240208 22:42:47 server id 1  end_log_pos 661 CRC32 0x4aefc88b 	Query	thread_id=5	exec_time=0	error_code=1492
      SET TIMESTAMP=1707424967/*!*/;
      CREATE OR REPLACE TABLE t (a INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME LIMIT 1000
      

      Attachments

        Issue Links

          Activity

            People

              Elkin Andrei Elkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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