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

ER_LOCK_DEADLOCK on concurrent read and insert into already locked gap

    XMLWordPrintable

Details

    Description

      mysql_ha_read: Got error 149 when reading table and ER_LOCK_DEADLOCK on concurrent reading/updating versioned partitioned table

      Notes:

      • The test case in the given form fails for in the first few attempts, but it can vary on different machines and builds; run with --repeat=N.
      • There are a couple of lines in the middle of the test which are unimportant for the error, but they help with the timing, without them it fails less reliably. The can probably be replaced with a proper synchronization.
      • I am not sure if the deadlock and the error in the log always come together. Please not that the error in the log alone does not make an MTR test fail, because it's currently suppressed in include/mtr_warnings.sql. We are considering removing the suppression, but first we need to check how many of existing tests would be affected. Meanwhile, if you need the test to fail upon the log error, remove the suppression from the file locally.
      • The problem might be not related to versioning, but I couldn't remove either versioning or partitioning from the test case.

      --source include/have_innodb.inc
      --source include/have_partition.inc
       
      CREATE TABLE t1 (
        pk INT,
        c CHAR(32),
        PRIMARY KEY (pk)
      ) ENGINE=InnoDB WITH SYSTEM VERSIONING PARTITION BY HASH(pk) PARTITIONS 2;
       
      INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
      HANDLER t1 OPEN AS h;
       
      --connect (con1,localhost,root,,test)
      --send
        UPDATE t1 SET c = 4;
       
      --connection default
       
      # Two statements below are not required for the scenario,
      # but apparently they help with the timing, it fails better with them
      --error ER_UNKNOWN_TABLE
      HANDLER unknown_handler CLOSE;
      --error ER_NO_SUCH_TABLE
      HANDLER unknown_table OPEN;
       
      HANDLER h READ `PRIMARY` PREV;
       
      # Cleanup
       
      --connection con1
      --reap
      --disconnect con1
      --connection default
      HANDLER h CLOSE;
      DROP TABLE t1;
      

      10.3 4946eb7b

      mysqltest: At line 26: query 'HANDLER h READ `PRIMARY` PREV' failed: 1213: Deadlock found when trying to get lock; try restarting transaction
      

      CURRENT_TEST: bug.error149b
      2019-02-23 21:55:43 19 [ERROR] mysql_ha_read: Got error 149 when reading table 'h'
      

      Attachments

        1. failing_thread.txt
          4 kB
        2. tampering_thread.txt
          4 kB
        3. v.test
          1 kB

        Issue Links

          Activity

            People

              vlad.lesin Vladislav Lesin
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              7 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.