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

InnoDB: Cannot replay rename … because the target file exists

    XMLWordPrintable

Details

    • Can result in unexpected behaviour
    • InnoDB could fail to start up if crash recovery involves multiple RENAME operations.
    • Q4/2026 Server Maintenance

    Description

      InnoDB may fail to start up if crash recovery would have to rename multiple files:

      --source include/have_innodb.inc
      --source include/not_embedded.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB;
      CREATE TABLE t2 (a INT) ENGINE=InnoDB;
      SET GLOBAL innodb_log_checkpoint_now=ON;
      RENAME TABLE t2 TO t3, t1 TO t2;
      --source include/kill_mysqld.inc
      --move_file $MARIADB_DATADIR/test/t2.ibd $MARIADB_DATADIR/test/t1.ibd
      --move_file $MARIADB_DATADIR/test/t3.ibd $MARIADB_DATADIR/test/t2.ibd
      --source include/start_mysqld.inc
      SELECT * FROM t2, t3;
      DROP TABLE t2, t3;
      

      10.11 7ba0776692658dbfe02b30e135999b11288cae32

      2026-10-15  8:03:28 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=57717
      2026-10-15  8:03:28 0 [Note] InnoDB: Ignoring data file './test/t3.ibd' with space ID 6. Another data file called ./test/t2.ibd exists with the same space ID.
      2026-10-15  8:03:28 0 [Note] InnoDB: Ignoring data file './test/t2.ibd' with space ID 5. Another data file called ./test/t1.ibd exists with the same space ID.
      2026-10-15  8:03:28 0 [Note] InnoDB: End of log at LSN=61004
      2026-10-15  8:03:28 0 [ERROR] InnoDB: Cannot replay rename of tablespace 5 from './test/t1.ibd' to './test/t2.ibd' because the target file exists
      2026-10-15  8:03:28 0 [Note] InnoDB: Set innodb_force_recovery=1 to ignore corrupted pages.
      

      The above scenario is derived from MDEV-14992 (BACKUP SERVER):

      --source include/have_innodb.inc
      --source include/have_debug_sync.inc
      CREATE TABLE t1 (a INT) ENGINE=InnoDB;
      CREATE TABLE t2 (a INT) ENGINE=InnoDB;
      SET GLOBAL innodb_log_checkpoint_now=ON;
      --let $target= $MYSQLTEST_VARDIR/tmp/backup
      --connect backup,localhost,root
      SET DEBUG_SYNC='innodb_backup_start SIGNAL started WAIT_FOR renamed';
      --send_eval BACKUP SERVER TO '$target'
      --connection default
      SET DEBUG_SYNC='now WAIT_FOR started';
      RENAME TABLE t2 TO t3, t1 TO t2;
      SET DEBUG_SYNC='now SIGNAL renamed';
      --connection backup
      --reap
      --connection default
      --exec cat $MYSQLTEST_VARDIR/my.cnf >> $target/backup.cnf
      --let $restart_parameters= --defaults-file=$target/backup.cnf --datadir=$target
      --source include/restart_mysqld.inc
      SELECT * FROM t2, t3;
      --let $restart_parameters=
      --source include/restart_mysqld.inc
      DROP TABLE t2, t3;
      --rmdir $target
      

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              marko Marko Mäkelä
              Thirunarayanan Balathandayuthapani Thirunarayanan Balathandayuthapani
              Marko Mäkelä Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Git Integration

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