summaryrefslogtreecommitdiff
path: root/extra/mariabackup/encryption_plugin.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-06-30 10:49:37 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-07-05 11:43:28 +0300
commit8c71c6aa8b9f4c78cfa164fad1d324ba0cf9b888 (patch)
tree018dc06431015490e06196316ef334e492431e6d /extra/mariabackup/encryption_plugin.cc
parentdc722559cc996950a6f13ba62fa675ff2fa9828a (diff)
downloadmariadb-git-8c71c6aa8b9f4c78cfa164fad1d324ba0cf9b888.tar.gz
MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2
InnoDB I/O and buffer pool interfaces and the redo log format have been changed between MariaDB 10.1 and 10.2, and the backup code has to be adjusted accordingly. The code has been simplified, and many memory leaks have been fixed. Instead of the file name xtrabackup_logfile, the file name ib_logfile0 is being used for the copy of the redo log. Unnecessary InnoDB startup and shutdown and some unnecessary threads have been removed. Some help was provided by Vladislav Vaintroub. Parameters have been cleaned up and aligned with those of MariaDB 10.2. The --dbug option has been added, so that in debug builds, --dbug=d,ib_log can be specified to enable diagnostic messages for processing redo log entries. By default, innodb_doublewrite=OFF, so that --prepare works faster. If more crash-safety for --prepare is needed, double buffering can be enabled. The parameter innodb_log_checksums=OFF can be used to ignore redo log checksums in --backup. Some messages have been cleaned up. Unless --export is specified, Mariabackup will not deal with undo log. The InnoDB mini-transaction redo log is not only about user-level transactions; it is actually about mini-transactions. To avoid confusion, call it the redo log, not transaction log. We disable any undo log processing in --prepare. Because MariaDB 10.2 supports indexed virtual columns, the undo log processing would need to be able to evaluate virtual column expressions. To reduce the amount of code dependencies, we will not process any undo log in prepare. This means that the --export option must be disabled for now. This also means that the following options are redundant and have been removed: xtrabackup --apply-log-only innobackupex --redo-only In addition to disabling any undo log processing, we will disable any further changes to data pages during --prepare, including the change buffer merge. This means that restoring incremental backups should reliably work even when change buffering is being used on the server. Because of this, preparing a backup will not generate any further redo log, and the redo log file can be safely deleted. (If the --export option is enabled in the future, it must generate redo log when processing undo logs and buffered changes.) In --prepare, we cannot easily know if a partial backup was used, especially when restoring a series of incremental backups. So, we simply warn about any missing files, and ignore the redo log for them. FIXME: Enable the --export option. FIXME: Improve the handling of the MLOG_INDEX_LOAD record, and write a test that initiates a backup while an ALGORITHM=INPLACE operation is creating indexes or rebuilding a table. An error should be detected when preparing the backup. FIXME: In --incremental --prepare, xtrabackup_apply_delta() should ensure that if FSP_SIZE is modified, the file size will be adjusted accordingly.
Diffstat (limited to 'extra/mariabackup/encryption_plugin.cc')
-rw-r--r--extra/mariabackup/encryption_plugin.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/extra/mariabackup/encryption_plugin.cc b/extra/mariabackup/encryption_plugin.cc
index 8f7741b057a..76512c185e2 100644
--- a/extra/mariabackup/encryption_plugin.cc
+++ b/extra/mariabackup/encryption_plugin.cc
@@ -8,6 +8,7 @@
#include <vector>
#include <common.h>
#include <backup_mysql.h>
+#include <log0crypt.h>
extern struct st_maria_plugin *mysql_optional_plugins[];
@@ -18,14 +19,14 @@ extern char *xb_plugin_load;
extern char *xb_plugin_dir;
const int PLUGIN_MAX_ARGS = 1024;
-vector<string> backup_plugins_args;
+std::vector<std::string> backup_plugins_args;
const char *QUERY_PLUGIN =
"SELECT plugin_name, plugin_library, @@plugin_dir"
" FROM information_schema.plugins WHERE plugin_type='ENCRYPTION'"
" AND plugin_status='ACTIVE'";
-string encryption_plugin_config;
+std::string encryption_plugin_config;
static void add_to_plugin_load_list(const char *plugin_def)
{
@@ -38,7 +39,7 @@ void encryption_plugin_backup_init(MYSQL *mysql)
{
MYSQL_RES *result;
MYSQL_ROW row;
- ostringstream oss;
+ std::ostringstream oss;
char *argv[PLUGIN_MAX_ARGS];
int argc;
@@ -59,17 +60,17 @@ void encryption_plugin_backup_init(MYSQL *mysql)
if (*p == '\\') *p = '/';
#endif
- string plugin_load(name);
+ std::string plugin_load(name);
if (library)
- plugin_load += string("=") + library;
+ plugin_load += std::string("=") + library;
- oss << "plugin_load=" << plugin_load << endl;
+ oss << "plugin_load=" << plugin_load << std::endl;
/* Required to load the plugin later.*/
add_to_plugin_load_list(plugin_load.c_str());
strncpy(opt_plugin_dir, dir, FN_REFLEN);
- oss << "plugin_dir=" << '"' << dir << '"' << endl;
+ oss << "plugin_dir=" << '"' << dir << '"' << std::endl;
/* Read plugin variables. */
@@ -80,12 +81,12 @@ void encryption_plugin_backup_init(MYSQL *mysql)
result = xb_mysql_query(mysql, query, true, true);
while ((row = mysql_fetch_row(result)))
{
- string arg("--");
+ std::string arg("--");
arg += row[0];
arg += "=";
arg += row[1];
backup_plugins_args.push_back(arg);
- oss << row[0] << "=" << row[1] << endl;
+ oss << row[0] << "=" << row[1] << std::endl;
}
mysql_free_result(result);
@@ -94,7 +95,7 @@ void encryption_plugin_backup_init(MYSQL *mysql)
result = xb_mysql_query(mysql, "select @@innodb_encrypt_log", true, true);
row = mysql_fetch_row(result);
srv_encrypt_log = (row != 0 && row[0][0] == '1');
- oss << "innodb_encrypt_log=" << row[0] << endl;
+ oss << "innodb_encrypt_log=" << row[0] << std::endl;
mysql_free_result(result);