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

mysql_upgrade fails with sql_notes=OFF

    XMLWordPrintable

Details

    Description

      mysql_upgrade, more exactly mysql_system_tables.sql, uses @@warning_count variable in the upgrade logic. The variable, in turn, depends on the value of sql_notes. It is ON by default, but when it is OFF, @@warnings_count is not incremented, and mysql_upgrade doesn't work as expected:

      --source include/have_innodb.inc
       
      set global sql_notes= 0;
      --exec $MYSQL_UPGRADE
      

      10.3 644d9f38

      ERROR 1062 (23000) at line 617: Duplicate entry 'localhost-root--' for key 'PRIMARY'
      FATAL ERROR: Upgrade failed
      

      Apparently it happens always, on major and minor upgrades alike.

      It wasn't very important before, as having it set to OFF before the upgrade is probably quite uncommon and means that the upgrade is run manually; and setting the value back to ON and re-running mysql_upgrade fixes the problem.

      However, it becomes a bit more serious with the introduction of the new owner for mysql.user in the scope of MDEV-19650, as now, upon major upgrade (from pre-"mariadb.sys" version) after the initial failure setting the value back to ON and re-running mysql_upgrade does not fix the database, it remains inconsistent:

      bb-10.4-MDEV-19650 15a750f2501b5ea8a5bc09c7047b8cef7e92d6ab

      Phase 3/7: Fixing views
      mysql.user
      Error    : The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      error    : Corrupt
      Phase 4/7: Running 'mysql_fix_privilege_tables'
      ERROR 1449 (HY000) at line 7: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 16: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 59: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 68: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 86: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 172: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 181: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 183: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 194: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 199: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 202: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 326: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 329: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 397: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 402: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 404: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 407: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 411: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 416: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 432: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      ERROR 1449 (HY000) at line 440: The user specified as a definer ('mariadb.sys'@'localhost') does not exist
      FATAL ERROR: Upgrade failed
      

      For the convenience, below is is the test case for this failure. The dump file which it uses is attached. Dump is not important, the problem happens on a normal live upgrade from a version which doesn't have a pre-existing mariadb.sys user.

      --source include/have_innodb.inc
       
      --exec cp -r $MYSQLTEST_VARDIR/install.db $MYSQL_TMP_DIR/data
      --let $restart_parameters= --datadir=$MYSQL_TMP_DIR/data
      --source include/restart_mysqld.inc
       
      --exec $MYSQL mysql < /tmp/10.3.mysql.dump
      flush privileges;
       
      set global sql_notes= 0;
      --error 1
      --exec $MYSQL_UPGRADE
       
      set global sql_notes= 1;
      --exec $MYSQL_UPGRADE
       
      --let $restart_parameters=
      --source include/restart_mysqld.inc
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              3 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.