Skip to content

Commit c0db3fe

Browse files
sloonzrobertbindar
authored andcommitted
MDEV-18438 Don't stream xtrabackup_info of extra-lsndir
1 parent f94d9ab commit c0db3fe

File tree

8 files changed

+62
-10
lines changed

8 files changed

+62
-10
lines changed

extra/mariabackup/backup_copy.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,8 @@ bool backup_finish()
16101610
return(false);
16111611
}
16121612

1613-
if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO, opt_history != 0)) {
1613+
if (!write_xtrabackup_info(mysql_connection, XTRABACKUP_INFO,
1614+
opt_history != 0, true)) {
16141615
return(false);
16151616
}
16161617

extra/mariabackup/backup_mysql.cc

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,9 +1472,12 @@ PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the
14721472
table containing all the history info particular to the just completed
14731473
backup. */
14741474
bool
1475-
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
1475+
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
1476+
bool stream)
14761477
{
14771478

1479+
bool result = true;
1480+
FILE *fp = NULL;
14781481
char *uuid = NULL;
14791482
char *server_version = NULL;
14801483
char buf_start_time[100];
@@ -1500,7 +1503,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
15001503
|| xtrabackup_databases_exclude
15011504
);
15021505

1503-
backup_file_printf(filename,
1506+
char *buf = NULL;
1507+
int buf_len = asprintf(&buf,
15041508
"uuid = %s\n"
15051509
"name = %s\n"
15061510
"tool_name = %s\n"
@@ -1512,8 +1516,8 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
15121516
"end_time = %s\n"
15131517
"lock_time = %d\n"
15141518
"binlog_pos = %s\n"
1515-
"innodb_from_lsn = %llu\n"
1516-
"innodb_to_lsn = %llu\n"
1519+
"innodb_from_lsn = " LSN_PF "\n"
1520+
"innodb_to_lsn = " LSN_PF "\n"
15171521
"partial = %s\n"
15181522
"incremental = %s\n"
15191523
"format = %s\n"
@@ -1530,12 +1534,34 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
15301534
(int)history_lock_time, /* lock_time */
15311535
mysql_binlog_position ?
15321536
mysql_binlog_position : "", /* binlog_pos */
1533-
incremental_lsn, /* innodb_from_lsn */
1534-
metadata_to_lsn, /* innodb_to_lsn */
1537+
incremental_lsn,
1538+
/* innodb_from_lsn */
1539+
metadata_to_lsn,
1540+
/* innodb_to_lsn */
15351541
is_partial? "Y" : "N",
15361542
xtrabackup_incremental ? "Y" : "N", /* incremental */
15371543
xb_stream_name[xtrabackup_stream_fmt], /* format */
15381544
xtrabackup_compress ? "compressed" : "N"); /* compressed */
1545+
if (buf_len < 0) {
1546+
msg("Error: cannot generate xtrabackup_info");
1547+
result = false;
1548+
goto cleanup;
1549+
}
1550+
1551+
if (stream) {
1552+
backup_file_printf(filename, "%s", buf);
1553+
} else {
1554+
fp = fopen(filename, "w");
1555+
if (!fp) {
1556+
msg("Error: cannot open %s", filename);
1557+
result = false;
1558+
goto cleanup;
1559+
}
1560+
if (fwrite(buf, buf_len, 1, fp) < 1) {
1561+
result = false;
1562+
goto cleanup;
1563+
}
1564+
}
15391565

15401566
if (!history) {
15411567
goto cleanup;
@@ -1597,8 +1623,11 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history)
15971623

15981624
free(uuid);
15991625
free(server_version);
1626+
free(buf);
1627+
if (fp)
1628+
fclose(fp);
16001629

1601-
return(true);
1630+
return(result);
16021631
}
16031632

16041633
extern const char *innodb_checksum_algorithm_names[];

extra/mariabackup/backup_mysql.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ bool
6868
write_binlog_info(MYSQL *connection);
6969

7070
bool
71-
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history);
71+
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
72+
bool stream);
7273

7374
bool
7475
write_backup_config_file();

extra/mariabackup/xtrabackup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3984,7 +3984,7 @@ static bool xtrabackup_backup_low()
39843984
}
39853985
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir,
39863986
XTRABACKUP_INFO);
3987-
if (!write_xtrabackup_info(mysql_connection, filename, false)) {
3987+
if (!write_xtrabackup_info(mysql_connection, filename, false, false)) {
39883988
msg("Error: failed to write info "
39893989
"to '%s'.", filename);
39903990
return false;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xtrabackup_checkpoints
2+
xtrabackup_info
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let $extra_lsndir=$MYSQLTEST_VARDIR/tmp/extra_lsndir;
2+
mkdir $extra_lsndir;
3+
--disable_result_log
4+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --stream=xbstream --extra-lsndir=$extra_lsndir > /dev/null;
5+
--enable_result_log
6+
list_files $extra_lsndir;
7+
rmdir $extra_lsndir;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stream.xb
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let $basedir=$MYSQLTEST_VARDIR/tmp/mdev-18438;
2+
mkdir $basedir;
3+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extra-lsndir=$basedir/extra_lsndir --stream=xbstream > $basedir/stream.xb;
4+
mkdir $basedir/backup;
5+
rmdir $basedir/extra_lsndir;
6+
--disable_result_log
7+
exec $XBSTREAM -x -C $basedir/backup < $basedir/stream.xb;
8+
--enable_result_log
9+
rmdir $basedir/backup;
10+
list_files $basedir;
11+
rmdir $basedir;

0 commit comments

Comments
 (0)