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

mysql_upgrade attempts to remove plugins which it failed to install

Details

    Description

      When mysql_upgrade is run on a MySQL datadir with JSON type, it attempts to install type_mysql_json. In reality, it is likely to fail (e.g. due to MDEV-26230).
      Further in the logic it attempts to uninstall previously installed plugins. Since it failed to install this one, it should be skipped upon uninstallation, but it is not:

      10.5 5518c320

      Checking for tables with unknown storage engine
      installing plugin for MYSQL_JSON data type
      ERROR 1126 (HY000) at line 1: Can't open shared library 'type_mysql_json.so' (errno: 1, Loading of alpha plugin MYSQL_JSON is prohibited by --plugin-maturity=gamma)
      Phase 3/7: Fixing views from mysql
      

      test.t
      Error    : Unknown data type: 'MYSQL_JSON'
      error    : Corrupt
      uninstalling plugin for 'type_mysql_json' data type
      ERROR 1305 (42000) at line 1: SONAME type_mysql_json.so does not exist
      Phase 7/7: Running 'FLUSH PRIVILEGES'
      

      Attachments

        Issue Links

          Activity

            Hi elenst,
            since MDEV-26230 is fixed this may be closed,right?
            I have tested on 10.6.16 and I don't see above behavior.

            anel Anel Husakovic added a comment - Hi elenst , since MDEV-26230 is fixed this may be closed,right? I have tested on 10.6.16 and I don't see above behavior.

            Naturally you can't see the described behavior if the description uses type_mysql_json as an example of a failing plugin and it doesn't fail anymore. This report is not about that, it is about mysql_upgrade not detecting / remembering whether it succeeded at installing something before or not, and trying to uninstall it anyway.

            So, if somebody can guarantee that no plugin will ever fail to install during mysql_upgrade, then sure, it can be closed on this reason.

            Another reason to close it could be that it doesn't matter. I can't remember now why it mattered that mysql_upgrade throws an additional error, even a meaningless one. It looks like a cosmetic issue, so I'll decrease the priority.

            elenst Elena Stepanova added a comment - Naturally you can't see the described behavior if the description uses type_mysql_json as an example of a failing plugin and it doesn't fail anymore. This report is not about that, it is about mysql_upgrade not detecting / remembering whether it succeeded at installing something before or not, and trying to uninstall it anyway. So, if somebody can guarantee that no plugin will ever fail to install during mysql_upgrade, then sure, it can be closed on this reason. Another reason to close it could be that it doesn't matter. I can't remember now why it mattered that mysql_upgrade throws an additional error, even a meaningless one. It looks like a cosmetic issue, so I'll decrease the priority.
            anel Anel Husakovic added a comment - - edited

            I have tried to create the verify the test case running the MariaDB mysql_upgrade binary on the MySQL 5.7 data directory.
            The way I have done it was through containers

            MySQL 5.7 datadir upgrade

            # MySQL  server
            $ docker run --name mysql-cont --rm -v"${PWD}/mysql-data-dir":/var/lib/mysql -p 127.0.0.1:3344:3306 -eMYSQL_ROOT_PASSWORD=secret -d mysql:5.7
            # MariaDB client
            $ ./client/mysql_upgrade -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp
            Reading datadir from the MariaDB server failed. Got the following error when executing the 'mysql' command line client
            ERROR 1193 (HY000) at line 1: Unknown system variable 'WSREP_ON'
            FATAL ERROR: Upgrade failed
            #  Noted that it {MariaDB}'s {mariadb} client binary was successful on connecting to the {MySQL} server
            $ ./client/mariadb -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp
            Welcome to the MariaDB monitor.  Commands end with ; or \g.
            Your MySQL connection id is 4
            Server version: 5.7.44 MySQL Community Server (GPL)
             
            Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
             
            Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
            

            The same was done on MySQL 8.0, just for testing and noted that caching_sha2_password is missing for tested mariadb and mysql_upgrade clients.

            MySQL 8.0 datadir upgrade

            # MySQL  server
            $ docker run --name mysql-cont --rm -v"${PWD}/mysql-data-dir":/var/lib/mysql -p 127.0.0.1:3344:3306 -eMYSQL_ROOT_PASSWORD=secret -d mysql
            # MariaDB client
            $ ./client/mysql_upgrade -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp
            Reading datadir from the MariaDB server failed. Got the following error when executing the 'mysql' command line client
            ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
            FATAL ERROR: Upgrade failed
             
            # MariaDB client
            $ ./client/mariadb -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp
            ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
            

            But in order to be sure that no error will be generated I'm suggesting the following patch

            Patch: Check if plugin is installed via string

            $ git diff
            diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
            index 617d5464e34..81e66ecf2c2 100644
            --- a/client/mysql_upgrade.c
            +++ b/client/mysql_upgrade.c
            @@ -1124,7 +1124,7 @@ static my_bool from_before_10_1()
             
             static void uninstall_plugins(void)
             {
            -  if (ds_plugin_data_types.length)
            +  if (strcmp(ds_plugin_data_types.str, "") > 0)
               {
                 char *plugins= ds_plugin_data_types.str;
                 char *next= get_line(plugins);
            @@ -1181,6 +1181,7 @@ static int install_used_plugin_data_types(void)
                     else
                     {
                       fprintf(stderr, "... can't %s\n", "INSTALL SONAME 'type_mysql_json'");
            +          dynstr_set(&ds_plugin_data_types, "");
                       return 1;
                     }
                   }
            

            Have created PR.
            Regards,
            Anel

            anel Anel Husakovic added a comment - - edited I have tried to create the verify the test case running the MariaDB mysql_upgrade binary on the MySQL 5.7 data directory. The way I have done it was through containers MySQL 5.7 datadir upgrade # MySQL server $ docker run --name mysql-cont -- rm - v "${PWD}/mysql-data-dir" : /var/lib/mysql -p 127.0.0.1:3344:3306 -eMYSQL_ROOT_PASSWORD=secret -d mysql:5.7 # MariaDB client $ . /client/mysql_upgrade -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp Reading datadir from the MariaDB server failed. Got the following error when executing the 'mysql' command line client ERROR 1193 (HY000) at line 1: Unknown system variable 'WSREP_ON' FATAL ERROR: Upgrade failed # Noted that it {MariaDB}'s {mariadb} client binary was successful on connecting to the {MySQL} server $ . /client/mariadb -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.44 MySQL Community Server (GPL)   Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. The same was done on MySQL 8.0, just for testing and noted that caching_sha2_password is missing for tested mariadb and mysql_upgrade clients. MySQL 8.0 datadir upgrade # MySQL server $ docker run --name mysql-cont -- rm - v "${PWD}/mysql-data-dir" : /var/lib/mysql -p 127.0.0.1:3344:3306 -eMYSQL_ROOT_PASSWORD=secret -d mysql # MariaDB client $ . /client/mysql_upgrade -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp Reading datadir from the MariaDB server failed. Got the following error when executing the 'mysql' command line client ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password .so: cannot open shared object file : No such file or directory FATAL ERROR: Upgrade failed   # MariaDB client $ . /client/mariadb -uroot -psecret -h127.0.0.1 -P3344 --protocol=tcp ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password .so: cannot open shared object file : No such file or directory But in order to be sure that no error will be generated I'm suggesting the following patch Patch: Check if plugin is installed via string $ git diff diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 617d5464e34..81e66ecf2c2 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1124,7 +1124,7 @@ static my_bool from_before_10_1() static void uninstall_plugins(void) { - if (ds_plugin_data_types.length) + if (strcmp(ds_plugin_data_types.str, "") > 0) { char *plugins= ds_plugin_data_types.str; char *next= get_line(plugins); @@ -1181,6 +1181,7 @@ static int install_used_plugin_data_types(void) else { fprintf(stderr, "... can't %s\n", "INSTALL SONAME 'type_mysql_json'"); + dynstr_set(&ds_plugin_data_types, ""); return 1; } } Have created PR. Regards, Anel

            Review sent. Need aditional input because the current patch doesn't seem to change anything logic wise.

            cvicentiu Vicențiu Ciorbaru added a comment - Review sent. Need aditional input because the current patch doesn't seem to change anything logic wise.

            People

              cvicentiu Vicențiu Ciorbaru
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.