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

Unreasonable block in repeatable read

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.7.2
    • None
    • Locking
    • None
    • Ubuntu 22.04

    Description

      When I tested the database repeatable read isolation level, I found a issue.
      As shown in the use case below, the delete statement is blocked. But in my opinion there is no lock conflict here and it should not be blocked.

      --- I see
      --- session 0 to init
      SET GLOBAL innodb_lock_wait_timeout = 20;
      SET GLOBAL lock_wait_timeout = 20;
      DROP TABLE IF EXISTS tuEkZFXW;
      CREATE TABLE tuEkZFXW (ID INT, VAL INT, c0 DOUBLE  PRIMARY KEY, c1 DECIMAL(55, 11) , c2 BOOLEAN );
      INSERT INTO tuEkZFXW (ID, VAL, c0, c1, c2) VALUES (460, 561, 6537.3885, 7569.5750, 1);
      INSERT INTO tuEkZFXW (ID, VAL, c0, c1, c2) VALUES (464, 566, 4044.8689, 8585.5846, 1);
       
      --- session 1
      SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
      BEGIN;
      --- session 2
      SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
      BEGIN;
      --- session 1
      INSERT INTO tuEkZFXW (ID, VAL, c0, c2) VALUES ( 468, 570, 7105.4030, 0);
      --- session 2
      DELETE FROM tuEkZFXW WHERE ( tuEkZFXW.c2 > 0 OR tuEkZFXW.c2 < 0) AND (tuEkZFXW.c0 >= 100); ---blocked
      --- session 1
      SELECT ID, VAL, tuEkZFXW.c0, tuEkZFXW.c1, tuEkZFXW.c2 FROM tuEkZFXW WHERE ( tuEkZFXW.c2 > 0 OR tuEkZFXW.c2 < 0) AND (tuEkZFXW.c0 >= 100) ORDER BY tuEkZFXW.ID;
      +------+------+-----------+------------------+------+
      | ID   | VAL  | c0        | c1               | c2   |
      +------+------+-----------+------------------+------+
      |  460 |  561 | 6537.3885 | 7569.57500000000 |    1 |
      |  464 |  566 | 4044.8689 | 8585.58460000000 |    1 |
      +------+------+-----------+------------------+------+
      2 rows in set (0.00 sec)
      COMMIT;
      --- session 2
      COMMIT;
       
      --- expected to see
      --- I see in PG
      ...
      --- session 2 (not block)
       DELETE FROM tuEkZFXW WHERE ( tuEkZFXW.c2 > 0 OR tuEkZFXW.c2 < 0) AND (tuEkZFXW.c0 >= 100);
      DELETE 3
      --- session 1 
      SELECT ID, VAL, tuEkZFXW.c0, tuEkZFXW.c1, tuEkZFXW.c2 FROM tuEkZFXW WHERE ( tuEkZFXW.c2 > 0 OR tuEkZFXW.c2 < 0) AND (tuEkZFXW.c0 >= 100) ORDER BY tuEkZFXW.ID;
       id  | val |    c0     |    c1    | c2 
      -----+-----+-----------+----------+----
       460 | 561 | 6537.3887 | 7569.575 |  1
       464 | 566 |  4044.869 | 8585.585 |  1
      (2 rows)
      ...
      

      Attachments

        Issue Links

          Activity

            People

              greenman Ian Gilfillan
              dlxue huicong xu
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.