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

Make the InnoDB dictionary header read-only

    XMLWordPrintable

Details

    Description

      We should make the InnoDB dictionary header page (page 7 in the system tablespace) read-only after the InnoDB system tablespace has been created.

      The purpose of the sequences DICT_HDR_TABLE_ID, DICT_HDR_INDEX_ID and DICT_HDR_MAX_SPACE_ID is to avoid duplicate entries in the data dictionary. We can follow up on MDEV-19506 and remove dict_hdr_get_new_id() altogether. That is, on startup, determine the maximum values of the identifiers by reading records from the data dictionary tables.

      We already traverse all of SYS_TABLES during startup and determine MAX(SYS_TABLES.SPACE). We might only need an extra lookup to determine MAX(SYS_INDEXES.ID).

      Because the buffer pool will be reinitialised during server startup, there should be no problem if the server had been killed during a DDL operation that had allocated a DICT_HDR_MAX_SPACE_ID. It is possible that the log-based recovery resurrected some uncommitted SYS_TABLES.SPACE in fil_system. They can be preserved.

      DROP TABLE may actually “rewind” MAX(SYS_TABLES.ID). To prevent glitches with some recovered undo log records that may have not been rolled back or purged yet, we should take the maximum of SYS_TABLES.ID and the maximum undo->table_id that we encountered while traversing all undo logs during startup.

      The main auxiliary use of SYS_INDEXES.ID is to facilitate page validation; PAGE_INDEX_ID in data pages must match it. If an index identifier is reused in some data file, pages with the old identifiers should already be unreachable via the persistent data dictionary. Also the adaptive hash index uses SYS_INDEXES.ID as a key. Because a server restart with empty it along with the buffer pool, reusing an index identifier that used to belong to a different index should not cause any trouble.

      After this change, the dictionary header page would only be consulted for the root page numbers and the index identifiers of the hard-coded dictionary tables SYS_TABLES, SYS_COLUMNS, SYS_INDEXES, SYS_FIELDS. There should be no need to access the dictionary header page outside InnoDB startup.

      Attachments

        Issue Links

          Activity

            People

              tafzeel Mohammad Tafzeel Shams
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.