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

UPDATE statements using subqueries behave weirdly under Read Uncommitted

    XMLWordPrintable

Details

    Description

      Isolation Level: Read Uncommitted.
      The behaviors of UPDATE statement using subqueries are weird. I speculate that dirty read performed by subqueries caused the problem with the UPDATE statements.

      Test case:

      /* init */ DROP TABLE IF EXISTS t0;
      /* init */ DROP TABLE IF EXISTS t1;
      /* init */ CREATE TABLE t0 (pkey INT PRIMARY KEY, value INT);
      /* init */ INSERT INTO t0 VALUES (1,20),(2,56);
      /* init */ CREATE TABLE t1 (pkey INT PRIMARY KEY, value INT, c0 INT);
      /* init */ INSERT INTO t1 VALUES (2,43,8),(3,57,53);
       
      /* t1 */ BEGIN;
      /* t1 */ UPDATE t0 SET value=162;
      /* t1 */ UPDATE t1 set c0=200 WHERE pkey=3;
      /* t2 */ BEGIN;
      /* t2 */ SELECT value FROM t1 WHERE c0 <= (SELECT MIN(value) FROM t0); -- [(43)]
      /* t2 */ UPDATE t1 SET value=100 WHERE c0 <= (SELECT MIN(value) FROM t0); -- blocked
      /* t1 */ COMMIT; -- t2 unblocked
      /* t2 */ COMMIT;

      UPDATE statement in transaction 2 updates the first row, but is blocked by the lock added to the second row.
      However, under Read Committed, UPDATE statement in transaction 2 is not blocked.

      Attachments

        Activity

          People

            marko Marko Mäkelä
            John Jove John Jove
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.