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

Failed TRUNCATE of a partitioned InnoDB table under LOCK TABLES with an alias leaves purge stopped, and shutdown hangs

    XMLWordPrintable

Details

    Description

      Likely cause: the fix for MDEV-36122, commit d1a67923244d835b4dad53842dc53a7cb3ff6053, in ha_innobase::truncate(). That fix made TRUNCATE stop purge while the table has more than one reference. CS 10.11.11, which does not have that fix, also gives ERROR 1205 here, but purge goes on.

      --source include/have_partition.inc
      --source include/have_innodb.inc
      --source include/have_sequence.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 2;
      INSERT INTO t1 VALUES (1), (2);
      LOCK TABLES t1 WRITE, t1 AS a1 READ;
      --error 0,ER_LOCK_WAIT_TIMEOUT
      ALTER TABLE t1 TRUNCATE PARTITION p0;
      UNLOCK TABLES;
      CREATE TABLE t2 (a INT) ENGINE=InnoDB;
      INSERT INTO t2 SELECT seq FROM seq_1_to_100;
      DELETE FROM t2;
      --let $n= 0
      --let $h= 1
      while ($h)
      {
        if ($n == 100)
        {
          --die InnoDB purge stays stopped after a failed TRUNCATE PARTITION under LOCK TABLES with an alias, and the history list length stays at $h
        }
        --sleep 0.1
        --let $h= query_get_value(SHOW GLOBAL STATUS LIKE 'Innodb_history_list_length', Value, 1)
        --inc $n
      }
      DROP TABLE t1, t2;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 06/10/2026

      mysqltest: At line 24: InnoDB purge stays stopped after a failed TRUNCATE PARTITION under LOCK TABLES with an alias, and the history list length stays at 11

      The ALTER TABLE ... TRUNCATE PARTITION gives ERROR 1205, and so does TRUNCATE TABLE t1. That error is MDEV-41734. After it, InnoDB purge stays stopped. The history list length does not go down, a later FLUSH TABLES t2 FOR EXPORT does not return, and a normal shutdown does not finish. The shutdown waits in srv_purge_shutdown(), and the purge coordinator loops in purge_sys_t::wait_FTS(). A view or a trigger that holds t1 in LOCK TABLES gives the same result. Without the alias, purge goes on. Debug builds give the same result.

      From the code it seems that ha_innobase::truncate() calls purge_sys.stop_FTS() when the table has a second reference (pause_purge), but calls purge_sys.resume_FTS() only when the table has a FULLTEXT index. ha_innobase::rename_table() resumes in both cases.

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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

                  Git Integration

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