Commit 58389c71 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 727324c1
......@@ -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);
......
......@@ -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 },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment