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

DDL allowed on a MERGE child table that is only READ-locked through its MERGE parent, once any other table is WRITE-locked

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.0, 13.1, 13.2
    • 10.11, 11.4, 11.8, 12.3, 13.0, 13.1
    • Locking
    • None
    • Can result in unexpected behaviour

    Description

      DDL allowed on a MERGE child table that is only READ-locked through its MERGE parent, once any other table is WRITE-locked

      CREATE TABLE m1 (a INT) ENGINE=MyISAM;
      CREATE TABLE w  (a INT) ENGINE=MyISAM;
      CREATE TABLE mm (a INT) ENGINE=MERGE UNION=(m1) INSERT_METHOD=LAST;
      INSERT INTO m1 VALUES (1),(2);
       
      LOCK TABLES mm READ;
      TRUNCATE TABLE m1;            # ERROR 1099 (correct)
      DROP TABLE m1;                # ERROR 1099 (correct)
      UNLOCK TABLES;
       
      LOCK TABLES mm READ, w WRITE;  # w is unrelated to mm
      SELECT COUNT(*) FROM mm;      # 2
      INSERT INTO m1 VALUES (3);    # ERROR 1099 (correct)
      TRUNCATE TABLE m1;            # succeeds  <-- expected ERROR 1099
      SELECT COUNT(*) FROM mm;      # 0         <-- READ-locked data removed
      ALTER TABLE m1 ADD COLUMN b INT;  # succeeds  <-- expected ERROR 1099
      DROP TABLE m1;                # succeeds  <-- expected ERROR 1099
      UNLOCK TABLES;
      SELECT * FROM mm;             # ERROR 1168
      

      13.2.0-opt>CREATE TABLE m1 (a INT) ENGINE=MyISAM;
      Query OK, 0 rows affected (0.007 sec)
       
      13.2.0-opt>CREATE TABLE w  (a INT) ENGINE=MyISAM;
      Query OK, 0 rows affected (0.003 sec)
       
      13.2.0-opt>CREATE TABLE mm (a INT) ENGINE=MERGE UNION=(m1) INSERT_METHOD=LAST;
      Query OK, 0 rows affected (0.003 sec)
       
      13.2.0-opt>INSERT INTO m1 VALUES (1),(2);
      Query OK, 2 rows affected (0.001 sec)
      Records: 2  Duplicates: 0  Warnings: 0
       
      13.2.0-opt>LOCK TABLES mm READ;
      Query OK, 0 rows affected (0.000 sec)
       
      13.2.0-opt>TRUNCATE TABLE m1;            # ERROR 1099 (correct)
      ERROR 1099 (HY000): Table 'm1' was locked with a READ lock and can't be updated
      13.2.0-opt>DROP TABLE m1;                # ERROR 1099 (correct)
      ERROR 1099 (HY000): Table 'm1' was locked with a READ lock and can't be updated
      13.2.0-opt>UNLOCK TABLES;
      Query OK, 0 rows affected (0.000 sec)
       
      13.2.0-opt>LOCK TABLES mm READ, w WRITE;  # w is unrelated to mm
      Query OK, 0 rows affected (0.000 sec)
       
      13.2.0-opt>SELECT COUNT(*) FROM mm;      # 2
      +----------+
      | COUNT(*) |
      +----------+
      |        2 |
      +----------+
      1 row in set (0.000 sec)
       
      13.2.0-opt>INSERT INTO m1 VALUES (3);    # ERROR 1099 (correct)
      ERROR 1099 (HY000): Table 'm1' was locked with a READ lock and can't be updated
      13.2.0-opt>TRUNCATE TABLE m1;            # succeeds  <-- expected ERROR 1099
      Query OK, 0 rows affected (0.000 sec)
       
      13.2.0-opt>SELECT COUNT(*) FROM mm;      # 0         <-- READ-locked data removed
      +----------+
      | COUNT(*) |
      +----------+
      |        0 |
      +----------+
      1 row in set (0.000 sec)
       
      13.2.0-opt>ALTER TABLE m1 ADD COLUMN b INT;  # succeeds  <-- expected ERROR 1099
      Query OK, 0 rows affected (0.008 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      13.2.0-opt>DROP TABLE m1;                # succeeds  <-- expected ERROR 1099
      Query OK, 0 rows affected (0.002 sec)
       
      13.2.0-opt>UNLOCK TABLES;
      Query OK, 0 rows affected (0.000 sec)
       
      13.2.0-opt>SELECT * FROM mm;             # ERROR 1168
      ERROR 1168 (HY000): Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
      13.2.0-opt>
      

      Attachments

        Activity

          People

            midenok Aleksey Midenkov
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 0.5h
                0.5h

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.