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

GTT: ERROR 1099: Table was locked with a READ lock and can't be updated on ALTER

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      CREATE TABLE t2 (c INT);
      LOCK TABLES t2 WRITE;
      CREATE OR REPLACE TEMPORARY TABLE t2 SELECT 0;
      ALTER TABLE t2 FORCE;
      

      Works fine:

      MDEV-35915-v11 CS 12.2.0 8934bac9ea05b79f7a5109d9e980cb939a24d4e3 (Debug, Clang 21.1.3-20250923) Build 19/01/2026

      12.2.0-dbg>ALTER TABLE t2 FORCE;
      Query OK, 1 row affected (0.000 sec)               
      Records: 1  Duplicates: 0  Warnings: 0
      

      However for the same testcase with GTT instead of TT:

      CREATE TABLE t2 (c INT);
      LOCK TABLES t2 WRITE;
      CREATE OR REPLACE GLOBAL TEMPORARY TABLE t2 SELECT 0;
      ALTER TABLE t2 FORCE;
      

      We see:

      MDEV-35915-v11 CS 12.2.0 8934bac9ea05b79f7a5109d9e980cb939a24d4e3 (Debug, Clang 21.1.3-20250923) Build 19/01/2026

      12.2.0-dbg>ALTER TABLE t2 FORCE;
      ERROR 1099 (HY000): Table 't2' was locked with a READ lock and can't be updated
      

      Verified to happen at least with InnoDB, MyISAM, and Aria.

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.