summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lipp <sloonz@gmail.com>2019-05-27 13:52:27 +0200
committerRobert Bindar <robert@mariadb.org>2019-09-19 17:47:54 +0300
commitc0db3fe6dabd2cb0df9bf532f54f9e8d233fa499 (patch)
tree45a375dc4328badb35491be1c0221f29a7f87cb2
parentf94d9ab9f8f03585f01f426e2479833a292527c4 (diff)
downloadmariadb-git-c0db3fe6dabd2cb0df9bf532f54f9e8d233fa499.tar.gz
MDEV-18438 Don't stream xtrabackup_info of extra-lsndir
-rw-r--r--extra/mariabackup/backup_copy.cc3
-rw-r--r--extra/mariabackup/backup_mysql.cc43
-rw-r--r--extra/mariabackup/backup_mysql.h3
-rw-r--r--extra/mariabackup/xtrabackup.cc2
-rw-r--r--mysql-test/suite/mariabackup/extra_lsndir_stream.result2
-rw-r--r--mysql-test/suite/mariabackup/extra_lsndir_stream.test7
-rw-r--r--mysql-test/suite/mariabackup/mdev-18438.result1
-rw-r--r--mysql-test/suite/mariabackup/mdev-18438.test11
8 files changed, 62 insertions, 10 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 28e5728bd3e..1db5eb16a52 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -1610,7 +1610,8 @@ bool backup_finish()
return(false);
}
- if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, opt_history != 0)) {
+ if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO,
+ opt_history != 0, true)) {
return(false);
}
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc
index 4c29b1e10c9..843ebf2663e 100644
--- a/extra/mariabackup/backup_mysql.cc
+++ b/extra/mariabackup/backup_mysql.cc
@@ -1472,9 +1472,12 @@ PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the
table containing all the history info particular to the just completed
backup. */
bool
-write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
+write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
+ bool stream)
{
+ bool result = true;
+ FILE *fp = NULL;
char *uuid = NULL;
char *server_version = NULL;
char buf_start_time[100];
@@ -1500,7 +1503,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
|| xtrabackup_databases_exclude
);
- backup_file_printf(filename,
+ char *buf = NULL;
+ int buf_len = asprintf(&buf,
"uuid = %s\n"
"name = %s\n"
"tool_name = %s\n"
@@ -1512,8 +1516,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
"end_time = %s\n"
"lock_time = %d\n"
"binlog_pos = %s\n"
- "innodb_from_lsn = %llu\n"
- "innodb_to_lsn = %llu\n"
+ "innodb_from_lsn = " LSN_PF "\n"
+ "innodb_to_lsn = " LSN_PF "\n"
"partial = %s\n"
"incremental = %s\n"
"format = %s\n"
@@ -1530,12 +1534,34 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
(int)history_lock_time, /* lock_time */
mysql_binlog_position ?
mysql_binlog_position : "", /* binlog_pos */
- incremental_lsn, /* innodb_from_lsn */
- metadata_to_lsn, /* innodb_to_lsn */
+ incremental_lsn,
+ /* innodb_from_lsn */
+ metadata_to_lsn,
+ /* innodb_to_lsn */
is_partial? "Y" : "N",
xtrabackup_incremental ? "Y" : "N", /* incremental */
xb_stream_name[xtrabackup_stream_fmt], /* format */
xtrabackup_compress ? "compressed" : "N"); /* compressed */
+ if (buf_len < 0) {
+ msg("Error: cannot generate xtrabackup_info");
+ result = false;
+ goto cleanup;
+ }
+
+ if (stream) {
+ backup_file_printf(filename, "%s", buf);
+ } else {
+ fp = fopen(filename, "w");
+ if (!fp) {
+ msg("Error: cannot open %s", filename);
+ result = false;
+ goto cleanup;
+ }
+ if (fwrite(buf, buf_len, 1, fp) < 1) {
+ result = false;
+ goto cleanup;
+ }
+ }
if (!history) {
goto cleanup;
@@ -1597,8 +1623,11 @@ cleanup:
free(uuid);
free(server_version);
+ free(buf);
+ if (fp)
+ fclose(fp);
- return(true);
+ return(result);
}
extern const char *innodb_checksum_algorithm_names[];
diff --git a/extra/mariabackup/backup_mysql.h b/extra/mariabackup/backup_mysql.h
index e2c56f88a8c..b61fa2362c6 100644
--- a/extra/mariabackup/backup_mysql.h
+++ b/extra/mariabackup/backup_mysql.h
@@ -68,7 +68,8 @@ bool
write_binlog_info(MYSQL *connection);
bool
-write_xtrabackup_info(MYSQL *connection, const char * filename, bool history);
+write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
+ bool stream);
bool
write_backup_config_file();
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index bc7149a87fd..46b67705700 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -3984,7 +3984,7 @@ static bool xtrabackup_backup_low()
}
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir,
XTRABACKUP_INFO);
- if (!write_xtrabackup_info(mysql_connection, filename, false)) {
+ if (!write_xtrabackup_info(mysql_connection, filename, false, false)) {
msg("Error: failed to write info "
"to '%s'.", filename);
return false;
diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.result b/mysql-test/suite/mariabackup/extra_lsndir_stream.result
new file mode 100644
index 00000000000..a25c45a13d1
--- /dev/null
+++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.result
@@ -0,0 +1,2 @@
+xtrabackup_checkpoints
+xtrabackup_info
diff --git a/mysql-test/suite/mariabackup/extra_lsndir_stream.test b/mysql-test/suite/mariabackup/extra_lsndir_stream.test
new file mode 100644
index 00000000000..97023cb179d
--- /dev/null
+++ b/mysql-test/suite/mariabackup/extra_lsndir_stream.test
@@ -0,0 +1,7 @@
+let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir;
+mkdir $extra_lsndir;
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream --extra-lsndir=$extra_lsndir > /dev/null;
+--enable_result_log
+list_files $extra_lsndir;
+rmdir $extra_lsndir;
diff --git a/mysql-test/suite/mariabackup/mdev-18438.result b/mysql-test/suite/mariabackup/mdev-18438.result
new file mode 100644
index 00000000000..ab3b81bd484
--- /dev/null
+++ b/mysql-test/suite/mariabackup/mdev-18438.result
@@ -0,0 +1 @@
+stream.xb
diff --git a/mysql-test/suite/mariabackup/mdev-18438.test b/mysql-test/suite/mariabackup/mdev-18438.test
new file mode 100644
index 00000000000..a6ec45476ff
--- /dev/null
+++ b/mysql-test/suite/mariabackup/mdev-18438.test
@@ -0,0 +1,11 @@
+let $basedir=$MYSQLTEST_VARDIR/tmp/mdev-18438;
+mkdir $basedir;
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extra-lsndir=$basedir/extra_lsndir --stream=xbstream > $basedir/stream.xb;
+mkdir $basedir/backup;
+rmdir $basedir/extra_lsndir;
+--disable_result_log
+exec $XBSTREAM -x -C $basedir/backup < $basedir/stream.xb;
+--enable_result_log
+rmdir $basedir/backup;
+list_files $basedir;
+rmdir $basedir;