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

intermediate files operations are not protected by backup locks

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • 10.6
    • 10.6.2
    • Backup, Server
    • None

    Description

      After MDEV-25666 fix mariabackup.innodb_ddl_on_intermediate_table fails with the following way:

      1. mariabackup holds "BACKUP STAGE START" (see MDEV-5336 for details).
      2. The server starts "ALTER TABLE" with "COPY" algorithm. copy_data_between_tables() is invoked and holds MDL_BACKUP_ALTER_COPY lock and copies data to intermediate table. InnoDB writes FILE_CREATE redo log record.
      3. mariabackup requests BLOCK_COMMIT lock, and the lock is granted. mariabackup remembers LSN just after the lock is granted.
      4. The server finishes data copying in copy_data_between_tables() and tries to upgrade the lock to MDL_BACKUP_DDL, which conflicts with the lock held by mariabackup. The lock request finishes by timeout and copy_data_between_tables() returns error.
      5. mysql_alter_table() drops intermediate table, this drop is not protected with MDL_BACKUP_DDL, so the table is dropped and InnoDB writes FILE_DELETE redo log record.
      6. mariabackup waits while redo log is read to the LSN remembered on the step 3. So FILE_CREATE for the intermediate table is read, but FILE_DELETE has not been read yet.
      7. mariabackup executes backup_fix_ddl(), and as FILE_CREATE was read, but FILE_DELETE was not read for the intermediate table, it tries to backup that table, and fails trying to open it, as it was deleted on step 5.

      Just for the note, mariabackup parses InnoDB redo log during backup and remembers all file operations read from the log, and then copies newly created files or creates special files for renamed and deleted files, which are processed during backup prepare phase.

      Before MDEV-25666 fix mariabackup ignored temp and intermediate tables, and backup_fix_ddl() worked well. But after this fix it does not work because intermediate file's operations are not protected with MDL_BACKUP_DDL lock.

      It's not obvious for me how to fix it or if this is bug or not. The transformation of #sql-* file into a real tablespace should not happen, and some BACKUP STAGE , or FTWRL should prevent that last rename during backup(see MDEV-5336). It might be that errors in MDEV-25666 log should not be treated as errors.

      The test: https://github.com/MariaDB/server/tree/10.6-MDEV-25899

      Attachments

        Issue Links

          Activity

            People

              wlad Vladislav Vaintroub
              vlad.lesin Vladislav Lesin
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.