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

Using check_constraint_checks=OFF can break replication

    XMLWordPrintable

Details

    • Can result in data loss
    • Replication would break (or diverge) with STATEMENT binlog format when check_constraint_checks was modified from the configured startup value because the variable was not written to the binary log with the affected event.

    Description

      I've tried this on 10.6 but other versions are likely to be affected.

      Put this into mysql-test/suite/rpl/t/rpl_check.test :

      source include/master-slave.inc;
       
      connection master;
       
      create table t10(
        pk int primary key, 
        a int, 
        constraint a_big check (a>10)
      );
       
      insert into t10 values (1, 20);
      set check_constraint_checks=off;
      update t10 set a=a-15 where pk=1;
      update t10 set a=a+100 where pk=1;
      set check_constraint_checks=on ;
      select * from t10;
       
      sync_slave_with_master;
       
      #  Here we are on the slave
      select * from t10;
      connection master;
       
      drop table t10;
      sync_slave_with_master;
       
      --source include/rpl_end.inc
      

      Run the test and it will fail with:

      CURRENT_TEST: rpl.rpl_check
      analyze: sync_with_master
      mysqltest: At line 20: sync_slave_with_master failed: 'select master_pos_wait('master-bin.000001', 1166, 300, '')' returned NULL indicating slave SQL thread failure
       
      ...
      Last_Error      Error 'CONSTRAINT `a_big` failed for `test`.`t10`' on query. Default database: 'test'. Query: 'update t10 set a=a-15 where pk=1'
      

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.