Skip to content

Commit b8514c9

Browse files
committed
MDEV-16496 Mariabackup: Implement --verbose option to instrument InnoDB log apply
srv_print_verbose_log: Introduce the value 2 to refer to mariabackup --verbose. recv_recover_page(), recv_parse_log_recs(): Add output for mariabackup --verbose.
1 parent ff317fe commit b8514c9

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
44
Originally Created 3/3/2009 Yasufumi Kinoshita
55
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
66
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
7-
(c) 2017, MariaDB Corporation.
7+
(c) 2017, 2018, MariaDB Corporation.
88
Portions written by Marko Mäkelä.
99
1010
This program is free software; you can redistribute it and/or modify
@@ -109,6 +109,7 @@ int sys_var_init();
109109
char xtrabackup_real_target_dir[FN_REFLEN] = "./xtrabackup_backupfiles/";
110110
char *xtrabackup_target_dir= xtrabackup_real_target_dir;
111111
static my_bool xtrabackup_version;
112+
static my_bool verbose;
112113
my_bool xtrabackup_backup;
113114
my_bool xtrabackup_prepare;
114115
my_bool xtrabackup_copy_back;
@@ -696,6 +697,9 @@ enum options_xtrabackup
696697

697698
struct my_option xb_client_options[] =
698699
{
700+
{"verbose", 'V', "display verbose output",
701+
(G_PTR*) &verbose, (G_PTR*) &verbose, 0, GET_BOOL, NO_ARG,
702+
FALSE, 0, 0, 0, 0, 0},
699703
{"version", 'v', "print xtrabackup version information",
700704
(G_PTR *) &xtrabackup_version, (G_PTR *) &xtrabackup_version, 0, GET_BOOL,
701705
NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -1756,7 +1760,7 @@ innodb_init_param(void)
17561760
srv_max_n_open_files = (ulint) innobase_open_files;
17571761
srv_innodb_status = (ibool) innobase_create_status_file;
17581762

1759-
srv_print_verbose_log = 1;
1763+
srv_print_verbose_log = verbose ? 2 : 1;
17601764

17611765
/* Store the default charset-collation number of this MySQL
17621766
installation */
@@ -3730,6 +3734,7 @@ static bool xtrabackup_backup_low()
37303734

37313735
if (metadata_to_lsn && xtrabackup_copy_logfile(true)) {
37323736
ds_close(dst_log_file);
3737+
dst_log_file = NULL;
37333738
return false;
37343739
}
37353740

mysql-test/suite/mariabackup/apply-log-only-incr.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ connection default;
3636

3737
--disable_result_log
3838
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir ;
39-
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir ;
39+
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir ;
4040
--enable_result_log
4141

4242
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test;
4343
--let SEARCH_PATTERN= Rolled back recovered transaction
4444
--source include/search_pattern_in_file.inc
4545
--echo # expect NOT FOUND
4646

47-
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
47+
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
4848

4949
--source include/search_pattern_in_file.inc
5050
--echo # expect NOT FOUND

mysql-test/suite/mariabackup/mdev-14447.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir
1818

1919
--disable_result_log
2020
echo # Prepare full backup, apply incremental one;
21-
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir;
22-
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
21+
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir;
22+
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
2323

2424
echo # Restore and check results;
2525
let $targetdir=$basedir;

storage/innobase/log/log0recv.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,11 @@ recv_recover_page(bool just_read_in, buf_block_t* block)
17721772

17731773
ut_ad(recv_needed_recovery);
17741774

1775+
if (UNIV_UNLIKELY(srv_print_verbose_log == 2)) {
1776+
fprintf(stderr, "Applying log to page %u:%u\n",
1777+
recv_addr->space, recv_addr->page_no);
1778+
}
1779+
17751780
DBUG_PRINT("ib_log",
17761781
("Applying log to page %u:%u",
17771782
recv_addr->space, recv_addr->page_no));
@@ -1872,6 +1877,13 @@ recv_recover_page(bool just_read_in, buf_block_t* block)
18721877
start_lsn = recv->start_lsn;
18731878
}
18741879

1880+
if (UNIV_UNLIKELY(srv_print_verbose_log == 2)) {
1881+
fprintf(stderr, "apply " LSN_PF ":"
1882+
" %d len " ULINTPF " page %u:%u\n",
1883+
recv->start_lsn, recv->type, recv->len,
1884+
recv_addr->space, recv_addr->page_no);
1885+
}
1886+
18751887
DBUG_PRINT("ib_log",
18761888
("apply " LSN_PF ":"
18771889
" %s len " ULINTPF " page %u:%u",
@@ -2422,6 +2434,16 @@ bool recv_parse_log_recs(lsn_t checkpoint_lsn, store_t store, bool apply)
24222434
#endif
24232435
lsn = mach_read_from_8(ptr + 1);
24242436

2437+
if (UNIV_UNLIKELY(srv_print_verbose_log == 2)) {
2438+
fprintf(stderr,
2439+
"MLOG_CHECKPOINT(" LSN_PF ") %s at "
2440+
LSN_PF "\n", lsn,
2441+
lsn != checkpoint_lsn ? "ignored"
2442+
: recv_sys->mlog_checkpoint_lsn
2443+
? "reread" : "read",
2444+
recv_sys->recovered_lsn);
2445+
}
2446+
24252447
DBUG_PRINT("ib_log",
24262448
("MLOG_CHECKPOINT(" LSN_PF ") %s at "
24272449
LSN_PF,

0 commit comments

Comments
 (0)