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

Handle InnoDB binlog position recovery for RESET MASTER or binlog name change

Details

    Description

      This is a re-filing of MDEV-22351.
      The original fix of MDEV-22351 was not working and has been reverted.

      The problem is demonstrated by a test case here:

      https://github.com/MariaDB/server/commits/knielsen_mdev22351

      With every transaction commit, InnoDB stores the corresponding binlog position in one of 128 slots in rseg headers. During recovery (or mariabackup --prepare), the most recent entry must be chosen as the one to recover.

      This is currently done by comparing (filename,offset) with lexicographical ordering. This usually works, because binlog files are named BASE.000001, BASE.000002, ...

      But if the server is restarted with a new basename that compares lower than the old, or if RESET MASTER is run, then an old entry can compare higher on the filename than a newer entry. This can lead to the old entry errorneously being recovered as the current binlog position.

      The above git branch contains a proof-of-concept fix that adds an incrementing version number to entries, but it requires extending the format of the entries in the rseg headers. This was deemed undesirable.

      An alternative fix is as suggested by Marko in MDEV-22351. If the server would inform storage engines when the filename of the binlog changes (from RESET MASTER, or a config change and server restart), then InnoDB can clear all the old entries and write a new entry with the correct current position. Such clear+write should probably be done as a single mini-transaction to make it crash-safe.

      Attachments

        Issue Links

          Activity

            Elkin Andrei Elkin added a comment -

            knielsen, to the future part related question, as a concept I consider to assign set @@seq_no = counter++ to the user trx near innobase_xa_prepare and
            exploit the same or refined/extended logics of the slave BGC that orders/waits-for commit parents.

            Elkin Andrei Elkin added a comment - knielsen , to the future part related question, as a concept I consider to assign set @@seq_no = counter++ to the user trx near innobase_xa_prepare and exploit the same or refined/extended logics of the slave BGC that orders/waits-for commit parents.

            Why not have mariabackup ask the server under BACKUP STAGE BLOCK_COMMIT for the current binlog position and store that as part of the backup?
            As there are no commits, the current binlog position is well known. This will also work if InnoDB would not be enabled.

            monty Michael Widenius added a comment - Why not have mariabackup ask the server under BACKUP STAGE BLOCK_COMMIT for the current binlog position and store that as part of the backup? As there are no commits, the current binlog position is well known. This will also work if InnoDB would not be enabled.

            MariaDB community backup is not using BACKUP STAGE BLOCK_COMMIT yet, but that should be fixed in 10.6 before next release

            monty Michael Widenius added a comment - MariaDB community backup is not using BACKUP STAGE BLOCK_COMMIT yet, but that should be fixed in 10.6 before next release
            Elkin Andrei Elkin added a comment -

            knielsen, marko, serg: could we consider an existing handlerton::ha_flush_logs and engine would get the intent of the binlog RESETing, rather than the binlog rotation, through some flag in current_thd?

            Elkin Andrei Elkin added a comment - knielsen , marko , serg : could we consider an existing handlerton::ha_flush_logs and engine would get the intent of the binlog RESETing, rather than the binlog rotation, through some flag in current_thd ?

            I think that this is waiting for serg to suggest a better solution than the two in the Description.

            marko Marko Mäkelä added a comment - I think that this is waiting for serg to suggest a better solution than the two in the Description.

            People

              serg Sergei Golubchik
              knielsen Kristian Nielsen
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.