Commit 8c4df595 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13807 mariabackup --apply-log-only does generate redo log by performing...

MDEV-13807 mariabackup --apply-log-only does generate redo log by performing rollback and possibly other tasks

Skip rollback and other redo-log-generating tasks if
srv_apply_log_only is set.

Instead of assigning the debug variable recv_no_log_write = FALSE,
assign it to srv_apply_log_only, so that any unwanted writes are caught.
parent 65d26d1f
call mtr.add_suppression("InnoDB: New log files created");
CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE INNODB;
INSERT INTO t VALUES(0);
COMMIT;
start transaction;
NOT FOUND /Rollback of trx with id/ in current_test
# expect NOT FOUND
NOT FOUND /Rollback of trx with id/ in current_test
# expect NOT FOUND
commit;
SELECT count(*) FROM t;
count(*)
201
# Restore and check results
# shutdown server
# remove datadir
# xtrabackup move back
# restart server
SELECT COUNT(*) FROM t;
COUNT(*)
1
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT COUNT(*) FROM t;
COUNT(*)
201
SELECT * FROM t;
a
0
DROP TABLE t;
--source include/have_innodb.inc
call mtr.add_suppression("InnoDB: New log files created");
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE INNODB;
INSERT INTO t VALUES(0);
COMMIT;
start transaction;
--disable_query_log
let $n=100;
while ($n) {
eval INSERT t VALUES(101-$n);
dec $n;
}
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
--enable_result_log
let $n=100;
while ($n) {
eval INSERT t VALUES(201-$n);
dec $n;
}
--enable_query_log
--disable_result_log
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 ;
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir ;
--enable_result_log
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test;
--let SEARCH_PATTERN= Rollback of trx with id
--source include/search_pattern_in_file.inc
--echo # expect NOT FOUND
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
--source include/search_pattern_in_file.inc
--echo # expect NOT FOUND
commit;
SELECT count(*) FROM t;
echo # Restore and check results;
--let $targetdir=$basedir
--let $restart_parameters= --innodb-force-recovery=3
--source include/restart_and_restore.inc
rmdir $basedir;
SELECT COUNT(*) FROM t;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT COUNT(*) FROM t;
--let $restart_parameters=
--source include/restart_mysqld.inc
SELECT * FROM t;
DROP TABLE t;
call mtr.add_suppression("InnoDB: New log files created");
CREATE TABLE t(a varchar(60)) ENGINE INNODB;
start transaction;
INSERT INTO t VALUES(1);
NOT FOUND /Rollback of trx with id/ in current_test
# expect NOT FOUND
SELECT count(*) FROM t;
count(*)
1
DROP TABLE t;
--source include/have_innodb.inc
call mtr.add_suppression("InnoDB: New log files created");
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
CREATE TABLE t(a varchar(60)) ENGINE INNODB;
start transaction;
INSERT INTO t VALUES(1);
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
--enable_result_log
exec $XTRABACKUP --prepare --apply-log-only --target-dir=$basedir ;
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/current_test;
--let SEARCH_PATTERN= Rollback of trx with id
--source include/search_pattern_in_file.inc
--echo # expect NOT FOUND
SELECT count(*) FROM t;
DROP TABLE t;
# Cleanup
rmdir $basedir;
...@@ -1980,7 +1980,7 @@ recv_apply_hashed_log_recs(bool last_batch) ...@@ -1980,7 +1980,7 @@ recv_apply_hashed_log_recs(bool last_batch)
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
mutex_enter(&(recv_sys->mutex)); mutex_enter(&(recv_sys->mutex));
ut_d(recv_no_log_write = FALSE); ut_d(recv_no_log_write = srv_apply_log_only);
recv_no_ibuf_operations = FALSE; recv_no_ibuf_operations = FALSE;
} }
...@@ -3461,7 +3461,8 @@ recv_recovery_from_checkpoint_finish(void) ...@@ -3461,7 +3461,8 @@ recv_recovery_from_checkpoint_finish(void)
that the data dictionary tables will be free of any locks. that the data dictionary tables will be free of any locks.
The data dictionary latch should guarantee that there is at The data dictionary latch should guarantee that there is at
most one data dictionary transaction active at a time. */ most one data dictionary transaction active at a time. */
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) { if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !srv_apply_log_only) {
trx_rollback_or_clean_recovered(FALSE); trx_rollback_or_clean_recovered(FALSE);
} }
} }
......
...@@ -2470,7 +2470,7 @@ srv_get_active_thread_type(void) ...@@ -2470,7 +2470,7 @@ srv_get_active_thread_type(void)
{ {
srv_thread_type ret = SRV_NONE; srv_thread_type ret = SRV_NONE;
if (srv_read_only_mode) { if (srv_read_only_mode || srv_apply_log_only) {
return(SRV_NONE); return(SRV_NONE);
} }
......
...@@ -767,7 +767,7 @@ create_log_files( ...@@ -767,7 +767,7 @@ create_log_files(
/* Create a log checkpoint. */ /* Create a log checkpoint. */
mutex_enter(&log_sys->mutex); mutex_enter(&log_sys->mutex);
ut_d(recv_no_log_write = FALSE); ut_d(recv_no_log_write = srv_apply_log_only);
recv_reset_logs( recv_reset_logs(
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
UT_LIST_GET_FIRST(log_sys->log_groups)->archived_file_no, UT_LIST_GET_FIRST(log_sys->log_groups)->archived_file_no,
...@@ -2748,6 +2748,11 @@ innobase_start_or_create_for_mysql() ...@@ -2748,6 +2748,11 @@ innobase_start_or_create_for_mysql()
recv_recovery_from_checkpoint_finish(); recv_recovery_from_checkpoint_finish();
if (srv_apply_log_only) {
ut_ad(IS_XTRABACKUP());
goto skip_processes;
}
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
/* The following call is necessary for the insert /* The following call is necessary for the insert
buffer to work with multiple tablespaces. We must buffer to work with multiple tablespaces. We must
...@@ -3156,6 +3161,7 @@ innobase_start_or_create_for_mysql() ...@@ -3156,6 +3161,7 @@ innobase_start_or_create_for_mysql()
os_thread_create(btr_defragment_thread, NULL, NULL); os_thread_create(btr_defragment_thread, NULL, NULL);
} }
skip_processes:
srv_was_started = TRUE; srv_was_started = TRUE;
return(DB_SUCCESS); return(DB_SUCCESS);
...@@ -3318,7 +3324,7 @@ innodb_shutdown() ...@@ -3318,7 +3324,7 @@ innodb_shutdown()
srv_misc_tmpfile = 0; srv_misc_tmpfile = 0;
} }
if (!srv_read_only_mode) { if (!srv_read_only_mode && !srv_apply_log_only) {
dict_stats_thread_deinit(); dict_stats_thread_deinit();
fil_crypt_threads_cleanup(); fil_crypt_threads_cleanup();
btr_scrub_cleanup(); btr_scrub_cleanup();
......
...@@ -122,9 +122,11 @@ trx_rseg_mem_free( ...@@ -122,9 +122,11 @@ trx_rseg_mem_free(
mutex_free(&rseg->mutex); mutex_free(&rseg->mutex);
if (!srv_apply_log_only) {
/* There can't be any active transactions. */ /* There can't be any active transactions. */
ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0); ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0);
ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0); ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0);
}
for (undo = UT_LIST_GET_FIRST(rseg->update_undo_cached); for (undo = UT_LIST_GET_FIRST(rseg->update_undo_cached);
undo != NULL; undo != NULL;
......
...@@ -1346,8 +1346,7 @@ trx_sys_close(void) ...@@ -1346,8 +1346,7 @@ trx_sys_close(void)
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == trx_sys->n_prepared_trx
|| srv_read_only_mode || srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO
|| (IS_XTRABACKUP() && srv_apply_log_only)); || srv_apply_log_only);
while ((trx = UT_LIST_GET_FIRST(trx_sys->rw_trx_list)) != NULL) { while ((trx = UT_LIST_GET_FIRST(trx_sys->rw_trx_list)) != NULL) {
trx_free_prepared(trx); trx_free_prepared(trx);
...@@ -1378,7 +1377,7 @@ trx_sys_close(void) ...@@ -1378,7 +1377,7 @@ trx_sys_close(void)
UT_LIST_REMOVE(view_list, trx_sys->view_list, prev_view); UT_LIST_REMOVE(view_list, trx_sys->view_list, prev_view);
} }
if (!IS_XTRABACKUP() || !srv_apply_log_only) { if (!srv_apply_log_only) {
ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0);
...@@ -1430,7 +1429,7 @@ ulint ...@@ -1430,7 +1429,7 @@ ulint
trx_sys_any_active_transactions(void) trx_sys_any_active_transactions(void)
/*=================================*/ /*=================================*/
{ {
if (IS_XTRABACKUP() && srv_apply_log_only) { if (srv_apply_log_only) {
return(0); return(0);
} }
mutex_enter(&trx_sys->mutex); mutex_enter(&trx_sys->mutex);
......
...@@ -483,6 +483,7 @@ trx_free_prepared( ...@@ -483,6 +483,7 @@ trx_free_prepared(
|| (trx_state_eq(trx, TRX_STATE_ACTIVE) || (trx_state_eq(trx, TRX_STATE_ACTIVE)
&& trx->is_recovered && trx->is_recovered
&& (srv_read_only_mode && (srv_read_only_mode
|| srv_apply_log_only
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO))); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO)));
ut_a(trx->magic_n == TRX_MAGIC_N); ut_a(trx->magic_n == TRX_MAGIC_N);
......
...@@ -2037,6 +2037,7 @@ trx_undo_free_prepared( ...@@ -2037,6 +2037,7 @@ trx_undo_free_prepared(
/* lock_trx_release_locks() assigns /* lock_trx_release_locks() assigns
trx->is_recovered=false */ trx->is_recovered=false */
ut_a(srv_read_only_mode ut_a(srv_read_only_mode
|| srv_apply_log_only
|| srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO); || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO);
break; break;
default: default:
......
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