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

mariabackup doesn't recognize encryption options provided on the command line

Details

    Description

      Till recently (I assume until MDEV-18215) one could override encryption options specified in the generated cnf file from the command line. It is convenient, for example, when you move the backup between hosts or environments, and paths change. It could look like this (notice file-key-management-filename treatment):

      10.4 9d479e25

      $ /data/bld/10.4-debug/bin/mariabackup --prepare --use-memory=1073741824  --innodb-file-io-threads=1 --target-dir=`pwd`/mdev23115/backup_before_prepare_0 --file-key-management-filename=`pwd`/mysql-test/std_data/keys.txt --plugin-dir=`pwd`/lib/plugin
      Warning: option 'innodb_file_io_threads': signed value 1 adjusted to 4
      /data/bld/10.4-debug/bin/mariabackup based on MariaDB server 10.4.14-MariaDB Linux (x86_64)
      [00] 2020-07-07 21:13:56 cd to /data/bld/10.5-debug-nightly/mdev23115/backup_before_prepare_0/
      [00] 2020-07-07 21:13:56 Loading encryption plugin from file_key_management=file_key_management
      [00] 2020-07-07 21:13:56 Loading encryption plugin
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--plugin_load=file_key_management=file_key_management'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--file_key_management_encryption_algorithm=aes_cbc'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--file_key_management_filekey='
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--file_key_management_filename=/xxhome/mdbe/data/file_key_management_keys.txt'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--innodb_encrypt_log=1'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--prepare'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--use-memory=1073741824'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--target-dir=/data/bld/10.5-debug-nightly/mdev23115/backup_before_prepare_0'
      [00] 2020-07-07 21:13:56 	 Encryption plugin parameter :  '--file-key-management-filename=/data/bld/10.5-debug-nightly/mysql-test/std_data/keys.txt'
      ...
      [00] 2020-07-07 21:13:58 completed OK!
      

      Now I don't seem to be able to do it anymore.
      If I try to put it on the command line as a "regular" mariabackup option, it rejects it:

      10.5 ee584137

      $ /data/bld/10.5-debug-nightly/bin/mariabackup --prepare --use-memory=1073741824  --innodb-file-io-threads=1 --target-dir=`pwd`/mdev23115/backup_before_prepare_0 --file-key-management-filename=`pwd`/mysql-test/std_data/keys.txt --plugin-dir=`pwd`/lib/plugin
      Warning: option 'innodb_file_io_threads': signed value 1 adjusted to 4
      Warning: option 'innodb_file_io_threads': signed value 1 adjusted to 4
      /data/bld/10.5-debug-nightly/bin/mariabackup: unknown variable 'file-key-management-filename=/data/bld/10.5-debug-nightly/mysql-test/std_data/keys.txt'
      

      And if I put it after mysqld-args, it gets ignored and the one from the cnf file is still used:

      $ /data/bld/10.5-debug-nightly/bin/mariabackup --prepare --use-memory=1073741824  --innodb-file-io-threads=1 --target-dir=`pwd`/mdev23115/backup_before_prepare_0 --plugin-dir=`pwd`/lib/plugin --mysqld-args --file-key-management-filename=`pwd`/mysql-test/std_data/keys.txt 
      Warning: option 'innodb_file_io_threads': signed value 1 adjusted to 4
      Warning: option 'innodb_file_io_threads': signed value 1 adjusted to 4
      /data/bld/10.5-debug-nightly/bin/mariabackup based on MariaDB server 10.5.5-MariaDB Linux (x86_64)
      [00] 2020-07-07 21:22:15 cd to /data/bld/10.5-debug-nightly/mdev23115/backup_before_prepare_0/
      [00] 2020-07-07 21:22:15 Loading encryption plugin from file_key_management=file_key_management
      [00] 2020-07-07 21:22:15 Loading encryption plugin
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--plugin_load=file_key_management=file_key_management'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--file_key_management_encryption_algorithm=aes_cbc'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--file_key_management_filekey='
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--file_key_management_filename=/xxhome/mdbe/data/file_key_management_keys.txt'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--innodb_encrypt_log=1'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--prepare'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--use-memory=1073741824'
      [00] 2020-07-07 21:22:15 	 Encryption plugin parameter :  '--target-dir=/data/bld/10.5-debug-nightly/mdev23115/backup_before_prepare_0'
      /data/bld/10.5-debug-nightly/bin/mariabackup: Can't find file: '/xxhome/mdbe/data/file_key_management_keys.txt' (errno: 2 "No such file or directory")
      

      Attachments

        Issue Links

          Activity

            Encryption plugin is initialized from xtrabackup_prepare_func():

            â–¾ encryption_plugin_init                                      
              â–¾ encryption_plugin_prepare_init
                â–¾ xtrabackup_prepare_func                                                   
                  â–¾ main_low
                    • main
            

            But the options are parsed before xtrabackup_prepare_func() call, in handle_options(), which is invoked from main().

            The fix can be in moving encryption_plugin_prepare_init() call from xtrabackup_prepare_func() to handle_options().

            vlad.lesin Vladislav Lesin added a comment - Encryption plugin is initialized from xtrabackup_prepare_func(): ▾ encryption_plugin_init ▾ encryption_plugin_prepare_init ▾ xtrabackup_prepare_func ▾ main_low • main But the options are parsed before xtrabackup_prepare_func() call, in handle_options(), which is invoked from main(). The fix can be in moving encryption_plugin_prepare_init() call from xtrabackup_prepare_func() to handle_options().

            It was apparently caused by

            commit 9bdf35e90f3
            Author: Vlad Lesin <vladislav.lesin@mariadb.com>
            Date:   Mon Jun 8 11:45:56 2020 +0300
             
                MDEV-18215: mariabackup does not report unknown command line options
                MDEV-21298: mariabackup doesn't read from the [mariadbd] and [mariadbd-X.Y]
                server option groups from configuration files
                MDEV-21301: mariabackup doesn't read [mariadb-backup] option group in
                configuration file
                
                All three issues require to change the same code, that is why their
                fixes are joined in one commit.
                
                The fix is in invoking load_defaults_or_exit() and handle_options() for
                backup-specific groups separately from client-server groups to let the last
                handle_options() call fail on unknown backup-specific options.
                
                The order of options procesing is the following:
                1) Load server groups and process server options, ignore unknown
                options
                2) Load client groups and process client options, ignore unknown
                options
                3) Load backup groups and process client-server options, exit on
                unknown option
                4) Process --mysqld-args command line options, ignore unknown options
            ...
            

            serg Sergei Golubchik added a comment - It was apparently caused by commit 9bdf35e90f3 Author: Vlad Lesin <vladislav.lesin@mariadb.com> Date: Mon Jun 8 11:45:56 2020 +0300   MDEV-18215: mariabackup does not report unknown command line options MDEV-21298: mariabackup doesn't read from the [mariadbd] and [mariadbd-X.Y] server option groups from configuration files MDEV-21301: mariabackup doesn't read [mariadb-backup] option group in configuration file All three issues require to change the same code, that is why their fixes are joined in one commit. The fix is in invoking load_defaults_or_exit() and handle_options() for backup-specific groups separately from client-server groups to let the last handle_options() call fail on unknown backup-specific options. The order of options procesing is the following: 1) Load server groups and process server options, ignore unknown options 2) Load client groups and process client options, ignore unknown options 3) Load backup groups and process client-server options, exit on unknown option 4) Process --mysqld-args command line options, ignore unknown options ...

            People

              vlad.lesin Vladislav Lesin
              elenst Elena Stepanova
              Votes:
              3 Vote for this issue
              Watchers:
              6 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.