summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-09-07 18:18:14 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-09-07 18:18:49 +0100
commit58389c71c2a041bc1c720745e7e5417b2ed7e8e5 (patch)
tree0d904ec9919cde6813782cc4f70f5bc51490a6cf /extra
parent727324c1e991f525dfd4a4d56d4cbb2cf97ed1e0 (diff)
downloadmariadb-git-58389c71c2a041bc1c720745e7e5417b2ed7e8e5.tar.gz
MDEV-16671 - crash in mariabackup with my.cnf with plugin-load=ha_rocksdb
Remove plugin-load option from mariabackup. It does not needed to be an option (we only need to store the plugin-load value during backup phase, and reuse the same value during --prepare). Fix is to read plugin-load from backup-my.cnf during prepare.
Diffstat (limited to 'extra')
-rw-r--r--extra/mariabackup/encryption_plugin.cc50
-rw-r--r--extra/mariabackup/xtrabackup.cc7
2 files changed, 48 insertions, 9 deletions
diff --git a/extra/mariabackup/encryption_plugin.cc b/extra/mariabackup/encryption_plugin.cc
index 76512c185e2..91dc526b2f2 100644
--- a/extra/mariabackup/encryption_plugin.cc
+++ b/extra/mariabackup/encryption_plugin.cc
@@ -35,6 +35,36 @@ static void add_to_plugin_load_list(const char *plugin_def)
static char XTRABACKUP_EXE[] = "xtrabackup";
+/*
+ Read "plugin-load" value (encryption plugin) from backup-my.cnf during
+ prepare phase.
+ The value is stored during backup phase.
+*/
+static std::string get_encryption_plugin_from_cnf()
+{
+ FILE *f = fopen("backup-my.cnf", "r");
+ if (!f)
+ {
+ msg("cannot open backup-my.cnf for reading\n");
+ exit(EXIT_FAILURE);
+ }
+ char line[512];
+ std::string plugin_load;
+ while (fgets(line, sizeof(line), f))
+ {
+ if (strncmp(line, "plugin_load=", 12) == 0)
+ {
+ plugin_load = line + 12;
+ // remote \n at the end of string
+ plugin_load.resize(plugin_load.size() - 1);
+ break;
+ }
+ }
+ fclose(f);
+ return plugin_load;
+}
+
+
void encryption_plugin_backup_init(MYSQL *mysql)
{
MYSQL_RES *result;
@@ -62,7 +92,17 @@ void encryption_plugin_backup_init(MYSQL *mysql)
std::string plugin_load(name);
if (library)
+ {
+ /* Remove shared library suffixes, in case we'll prepare on different OS.*/
+ const char *extensions[] = { ".dll", ".so", 0 };
+ for (size_t i = 0; extensions[i]; i++)
+ {
+ const char *ext = extensions[i];
+ if (ends_with(library, ext))
+ library[strlen(library) - strlen(ext)] = 0;
+ }
plugin_load += std::string("=") + library;
+ }
oss << "plugin_load=" << plugin_load << std::endl;
@@ -124,14 +164,18 @@ extern int finalize_encryption_plugin(st_plugin_int *plugin);
void encryption_plugin_prepare_init(int argc, char **argv)
{
-
- if (!xb_plugin_load)
+ std::string plugin_load= get_encryption_plugin_from_cnf();
+ if (plugin_load.size())
+ {
+ msg("Loading encryption plugin from %s\n", plugin_load.c_str());
+ }
+ else
{
finalize_encryption_plugin(0);
return;
}
- add_to_plugin_load_list(xb_plugin_load);
+ add_to_plugin_load_list(plugin_load.c_str());
if (xb_plugin_dir)
strncpy(opt_plugin_dir, xb_plugin_dir, FN_REFLEN);
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 1b295cead7c..4af5cc0d1d5 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -713,7 +713,6 @@ enum options_xtrabackup
OPT_INNODB_LOG_CHECKSUMS,
OPT_XTRA_INCREMENTAL_FORCE_SCAN,
OPT_DEFAULTS_GROUP,
- OPT_PLUGIN_LOAD,
OPT_INNODB_ENCRYPT_LOG,
OPT_CLOSE_FILES,
OPT_CORE_FILE,
@@ -1275,11 +1274,7 @@ struct my_option xb_server_options[] =
&xb_plugin_dir, &xb_plugin_dir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
- { "plugin-load", OPT_PLUGIN_LOAD, "encrypton plugin to load during 'prepare' phase.",
- &xb_plugin_load, &xb_plugin_load,
- 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
-
- { "innodb-encrypt-log", OPT_INNODB_ENCRYPT_LOG, "encrypton plugin to load",
+ { "innodb-encrypt-log", OPT_INNODB_ENCRYPT_LOG, "Whether to encrypt innodb log",
&srv_encrypt_log, &srv_encrypt_log,
0, GET_BOOL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },