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

slave lock timeout with xa and gap locks

    XMLWordPrintable

Details

    Description

      there are, perhaps, may ways that gap locks can be places differently on the master and on the slave. combined with 10.5+ XA binlogging (MDEV-742) this can cause locks to timeout on slaves. breaking replication. For example:

      # this test case can be run with read-committed (or higher) isolation leven
      source include/have_innodb.inc;
      source include/have_binlog_format_row.inc;
      source include/master-slave.inc;
      create table t1 (a int primary key, b int unique) engine=innodb;
      insert t1 values (1,1),(3,3),(5,5);
      sync_slave_with_master;
       
      # set a strong isolation level to keep the read view below.
      # alternatively a long-running select can do that too even in read-committed
      set session tx_isolation='repeatable-read';
      start transaction;
      # opens a read view to disable purge on the slave
      select * from t1;
       
      connect m2, localhost, root;
      # now, delete a value, purge it on the master, but not on the slave
      delete from t1 where a=3;
      xa start 'x1';
      # this sets a gap lock on <3>, when it exists (so, on the slave)
      update t1 set b=3 where a=5;
      xa end 'x1';
      xa prepare 'x1';
       
      connect m3, localhost, root;
      # and this tries to insert straight into the locked gap
      insert t1 values (2, 2);
       
      echo -->slave;
      sync_slave_with_master;
      commit;
      select * from t1;
       
      connection m2;
      xa rollback 'x1';
      drop table t1;
      source include/rpl_end.inc;
      

      A possible way to fix all lock timeouts on the slave caused by gap locks and XA is to release gap locks on XA prepare.

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              serg Sergei Golubchik
              Votes:
              0 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.