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

mysql_upgrade cannot repair versioned table which requires upgrade

    XMLWordPrintable

Details

    Description

      If a system-versioned table needs to be upgraded by the means of REPAIR, it requires a permissive value of system_versioning_alter_history (even if the table is empty).

      At least it is so for an encrypted system-versioned Aria table. The table in the provided data directory was created on current 10.4 with Aria encryption enabled and all other server options default, as

      CREATE TABLE t1 (a INT) ENGINE=aria WITH SYSTEM VERSIONING;
      

      and when 10.5 starts on this datadir, it claims that the table requires upgrade.

      10.5 969669767ba4f4dcfadbcc73d14d0904ad3c6aca

      MariaDB [test]> check table t1 for upgrade;
      +---------+-------+----------+---------------------------------------------------------------------------+
      | Table   | Op    | Msg_type | Msg_text                                                                  |
      +---------+-------+----------+---------------------------------------------------------------------------+
      | test.t1 | check | error    | Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! |
      +---------+-------+----------+---------------------------------------------------------------------------+
      1 row in set (0.002 sec)
      

      but cannot repair it

      MariaDB [test]> repair table t1;
      +---------+--------+----------+---------------------------------------------------------------------------------------------------------------+
      | Table   | Op     | Msg_type | Msg_text                                                                                                      |
      +---------+--------+----------+---------------------------------------------------------------------------------------------------------------+
      | test.t1 | repair | Error    | Not allowed for system-versioned `test`.`t1`. Change @@system_versioning_alter_history to proceed with ALTER. |
      | test.t1 | repair | status   | Operation failed                                                                                              |
      +---------+--------+----------+---------------------------------------------------------------------------------------------------------------+
      2 rows in set (0.002 sec)
      

      If I create a table without encryption, or if I change the engine to InnoDB, 10.5 doesn't say that it requires upgrade. Thus I cannot say how universal this requirement is for other engines and whether it's specific to encryption.

      If the variable is set to KEEP, REPAIR works. However, mysql_upgrade doesn't change the value, so it fails to upgrade such a table.

      Repairing tables
      test.t1
      Error    : Not allowed for system-versioned `test`.`t1`. Change @@system_versioning_alter_history to proceed with ALTER.
      status   : Operation failed
      Phase 7/7: Running 'FLUSH PRIVILEGES'
      

      I'm not sure whether it should be fixed on the server side, by lifting the requirement for system_versioning_alter_history=KEEP for REPAIR, or it should be fixed on the client side by just setting the value for the whole upgrade process.

      To run the server on the attached directory, start it with

      --aria-encrypt-tables=1 --file-key-management-filename=`pwd`/mysql-test/std_data/keys.txt --plugin-load-add=file_key_management
      

      assuming that your shell interprets `pwd` correctly and you have `pwd`/mysql-test/std_data/keys.txt file and the correct plugin directory (if the latter isn't true, point the plugin dir to the right location).

      Attachments

        Activity

          People

            serg Sergei Golubchik
            elenst Elena Stepanova
            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.