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

Failed CoR in non-atomic mode no longer generates DROP in RBR, replica diverges

Details

    Description

      --source include/have_binlog_format_row.inc
      --source include/master-slave.inc
       
      set drop_before_create_or_replace= on;
       
      create table t (a int);
      --error ER_DUP_ENTRY
      create or replace table t (a int primary key) as select 1 as a union all select 1;
      show binlog events;
      show tables;
       
      --sync_slave_with_master
      show tables;
       
      --connection master
      --source include/rpl_end.inc
      

      bb-main-monty 6cb6e8285c50a0bbcb2b599535b8d02b7bba5256

      show binlog events;
      Log_name	Pos	Event_type	Server_id	End_log_pos	Info
      master-bin.000001	4	Format_desc	1	256	Server ver: 12.0.0-MariaDB-debug-log, Binlog ver: 4
      master-bin.000001	256	Gtid_list	1	285	[]
      master-bin.000001	285	Binlog_checkpoint	1	329	master-bin.000001
      master-bin.000001	329	Gtid	1	371	GTID 0-1-1
      master-bin.000001	371	Query	1	469	use `test`; create table t (a int)
      show tables;
      Tables_in_test
      connection slave;
      show tables;
      Tables_in_test
      t
      

      Before MDEV-25292 (Atomic CREATE OR REPLACE), and with MDEV-28933 but in the statement binlog format, the non-atomic CREATE OR REPLACE drops the table, and a DROP event is written into the binary log. But after MDEV-25292, while it still drops the table because of drop_before_create_or_replace, the event is no longer generated, thus the table on the replica remains, and the servers diverge.

      Attachments

        Issue Links

          Activity

            Elkin Andrei Elkin added a comment -

            Could be a duplicated of just fixed MDEV-35499 Errored-out CREATE-or-REPLACE-SELECT does not log DROP table into binlog?
            Its commit is not present in the Monty's branch.

            Elkin Andrei Elkin added a comment - Could be a duplicated of just fixed MDEV-35499 Errored-out CREATE-or-REPLACE-SELECT does not log DROP table into binlog? Its commit is not present in the Monty's branch.
            elenst Elena Stepanova added a comment - - edited

            Thanks Elkin.

            I am not sure how to check whether it's quite the same problem. My test case from the description (minus the new option of course) doesn't fail even on 10.11.11 or on the current 10.6 which don't have the fix for MDEV-35499 – that is, both of them produce DROP event, and both primary and replica don't have the table after the failed CREATE OR REPLACE; and the patch for MDEV-35499 doesn't apply to Monty's branch, too many conflicts.

            I suppose we should better keep it open until the fix is merged up to main, and Monty's branch is rebased on it; or, alternatively, maybe monty can take a look and say right away whether MDEV-35499 will fix it or not.

            elenst Elena Stepanova added a comment - - edited Thanks Elkin . I am not sure how to check whether it's quite the same problem. My test case from the description (minus the new option of course) doesn't fail even on 10.11.11 or on the current 10.6 which don't have the fix for MDEV-35499 – that is, both of them produce DROP event, and both primary and replica don't have the table after the failed CREATE OR REPLACE; and the patch for MDEV-35499 doesn't apply to Monty's branch, too many conflicts. I suppose we should better keep it open until the fix is merged up to main, and Monty's branch is rebased on it; or, alternatively, maybe monty can take a look and say right away whether MDEV-35499 will fix it or not.
            Elkin Andrei Elkin added a comment -

            > I suppose we should better keep it open until the fix is merged up
            Totally makes sense.

            Elkin Andrei Elkin added a comment - > I suppose we should better keep it open until the fix is merged up Totally makes sense.

            I think my issue is different as the code that handles writing the drop from a failed create or replace is rewritten in my code.

            monty Michael Widenius added a comment - I think my issue is different as the code that handles writing the drop from a failed create or replace is rewritten in my code.

            I have fixed this in my branch. Will push together with MDEV-36555 shortly

            monty Michael Widenius added a comment - I have fixed this in my branch. Will push together with MDEV-36555 shortly
            monty Michael Widenius added a comment - - edited

            Fix pushed to bb-main-monty.
            The issue was that old code wrote to the binlog cache before binlog_reset_cache() was executed in sql_insert.cc:select_create::abort_result_set()
            Moving the writing to binlog cache after the above call fixed this issue

            monty Michael Widenius added a comment - - edited Fix pushed to bb-main-monty. The issue was that old code wrote to the binlog cache before binlog_reset_cache() was executed in sql_insert.cc:select_create::abort_result_set() Moving the writing to binlog cache after the above call fixed this issue

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.