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

DB_TRX_ID is not always reset when the history is removed

    XMLWordPrintable

Details

    • 10.3.6-1

    Description

      When an InnoDB transaction is about to update a record, two steps will be performed before the modification of the clustered index tree can start:

      1. the transaction must be able to acquire an exclusive lock on the record
      2. writing an undo log record for rolling back the operation must succeed

      This bug is about the undo log processing. We can get to that phase only if the record was last modified by a committed transaction.

      In the scenario of this bug, that committed transaction would still exist in the system in the purge queue, and the record would still carry a nonzero DB_TRX_ID:

      diff --git a/mysql-test/suite/innodb/t/dml_purge.test b/mysql-test/suite/innodb/t/dml_purge.test
      index 93b7f56111c..07d071517ff 100644
      --- a/mysql-test/suite/innodb/t/dml_purge.test
      +++ b/mysql-test/suite/innodb/t/dml_purge.test
      @@ -15,11 +15,23 @@ SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
       CREATE TABLE t1(a INT PRIMARY KEY, b INT NOT NULL)
       ROW_FORMAT=REDUNDANT ENGINE=InnoDB;
       
      +--connect (prevent_purge,localhost,root)
      +START TRANSACTION WITH CONSISTENT SNAPSHOT;
      +
      +--connection default
       INSERT INTO t1 VALUES(1,2),(3,4);
       UPDATE t1 SET b=-3 WHERE a=3;
       
      +--connect (con1,localhost,root)
      +BEGIN;
      +UPDATE t1 SET b=4 WHERE a=3;
      +--disconnect prevent_purge
      +
      +--connection default
       # Initiate a full purge, which should reset all DB_TRX_ID.
       --source include/wait_all_purged.inc
      +--disconnect con1
      +--source include/wait_all_purged.inc
       
       FLUSH TABLE t1 FOR EXPORT;
       # The following is based on innodb.table_flags:
      

      If the old transaction is purgeable, then we should write DB_TRX_ID=0 to the undo log record, so that in case our transaction is rolled back, the history will be reset at rollback.
      With the above modification to the test, there will be an unwanted result difference:

      @@ -19,8 +29,8 @@
        DB_ROLL_PTR=0x80000000000000,
        b=0x80000002)
       header=0x000018090074 (a=0x80000003,
      - DB_TRX_ID=0x000000000000,
      - DB_ROLL_PTR=0x80000000000000,
      + DB_TRX_ID=0x000000000026,
      + DB_ROLL_PTR=0x04000001370317,
        b=0x7ffffffd)
       header=0x030008030000 (a=0x73757072656d756d00)
       UNLOCK TABLES;
      

      In this report, there used to be a different test demonstrating a bug that affects all InnoDB versions since MySQL 3.23.49:
      MDEV-13603 innodb_fast_shutdown=0 may fail to purge all history

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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