From b8f4b984f9f23b336491c91c70be448b6fa8f095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 16 Dec 2022 17:08:56 +0200 Subject: MDEV-24685 fixup: Remove srv_n_file_io_threads The variable was not really being used for anything. The parameters innodb_read_io_threads, innodb_write_io_threads have replaced innodb_file_io_threads. --- extra/mariabackup/xtrabackup.cc | 8 -------- 1 file changed, 8 deletions(-) (limited to 'extra/mariabackup') diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index d41321e9bb9..1c64e0a8f2a 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2091,7 +2091,6 @@ static bool innodb_init_param() srv_buf_pool_size = (ulint) xtrabackup_use_memory; srv_buf_pool_chunk_unit = (ulong)srv_buf_pool_size; - srv_n_file_io_threads = (uint) innobase_file_io_threads; srv_n_read_io_threads = (uint) innobase_read_io_threads; srv_n_write_io_threads = (uint) innobase_write_io_threads; @@ -4486,7 +4485,6 @@ fail: xb_filters_init(); xb_fil_io_init(); - srv_n_file_io_threads = srv_n_read_io_threads; if (os_aio_init()) { msg("Error: cannot initialize AIO subsystem"); @@ -5965,12 +5963,6 @@ static bool xtrabackup_prepare_func(char** argv) fil_system.freeze_space_list = 0; - /* increase IO threads */ - if (srv_n_file_io_threads < 10) { - srv_n_read_io_threads = 4; - srv_n_write_io_threads = 4; - } - msg("Starting InnoDB instance for recovery."); msg("mariabackup: Using %lld bytes for buffer pool " -- cgit v1.2.1 From 5cec83476d969ac1b0d9914da4c81c5f58da24e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 21 Dec 2022 13:41:10 +0200 Subject: MDEV-29896: mariadb-backup --backup --incremental --throttle=... hangs io_watching_thread(): Declare as a detachable thread, similar to log_copying_thread(). stop_backup_threads(): Wait for both log_copying_thread and io_watching_thread to clear their flags. Expect log_sys.mutex to be held by the caller. xtrabackup_backup_func(): Initialize log_copying_stop before creating io_watching_thread. This prevents a race condition where io_watching_thread() could wait on the condition variable before it had been fully initialized. This race condition would cause a hang in the GNU libc implementation of pthread_cond_destroy() at the end of stop_backup_threads(). This race condition was introduced in commit 38fd7b7d9170369b16ff553f01669182e70bc9b5 (MDEV-21452). --- extra/mariabackup/xtrabackup.cc | 50 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'extra/mariabackup') diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 81f24337952..c7c89e56a80 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -190,6 +190,7 @@ struct xb_filter_entry_t{ lsn_t checkpoint_lsn_start; lsn_t checkpoint_no_start; static lsn_t log_copy_scanned_lsn; +/** whether log_copying_thread() is active; protected by log_sys.mutex */ static bool log_copying_running; int xtrabackup_parallel; @@ -3092,16 +3093,18 @@ static void log_copying_thread() my_thread_end(); } +/** whether io_watching_thread() is active; protected by log_sys.mutex */ static bool have_io_watching_thread; -static pthread_t io_watching_thread_id; /* io throttle watching (rough) */ -static void *io_watching_thread(void*) +static void io_watching_thread() { + my_thread_init(); /* currently, for --backup only */ - ut_a(xtrabackup_backup); + ut_ad(xtrabackup_backup); mysql_mutex_lock(&log_sys.mutex); + ut_ad(have_io_watching_thread); while (log_copying_running && !metadata_to_lsn) { @@ -3114,9 +3117,10 @@ static void *io_watching_thread(void*) /* stop io throttle */ xtrabackup_throttle= 0; + have_io_watching_thread= false; mysql_cond_broadcast(&wait_throttle); mysql_mutex_unlock(&log_sys.mutex); - return nullptr; + my_thread_end(); } #ifndef DBUG_OFF @@ -4377,27 +4381,29 @@ end: # define xb_set_max_open_files(x) 0UL #endif -static void stop_backup_threads(bool running) +static void stop_backup_threads() { - if (running) + mysql_cond_broadcast(&log_copying_stop); + + if (log_copying_running || have_io_watching_thread) { + mysql_mutex_unlock(&log_sys.mutex); fputs("mariabackup: Stopping log copying thread", stderr); fflush(stderr); - while (log_copying_running) + mysql_mutex_lock(&log_sys.mutex); + while (log_copying_running || have_io_watching_thread) { + mysql_cond_broadcast(&log_copying_stop); + mysql_mutex_unlock(&log_sys.mutex); putc('.', stderr); fflush(stderr); std::this_thread::sleep_for(std::chrono::milliseconds(200)); + mysql_mutex_lock(&log_sys.mutex); } putc('\n', stderr); - mysql_cond_destroy(&log_copying_stop); } - if (have_io_watching_thread) - { - pthread_join(io_watching_thread_id, nullptr); - mysql_cond_destroy(&wait_throttle); - } + mysql_cond_destroy(&log_copying_stop); } /** Implement the core of --backup @@ -4427,11 +4433,7 @@ static bool xtrabackup_backup_low() msg("Error: recv_find_max_checkpoint() failed."); } - mysql_cond_broadcast(&log_copying_stop); - const bool running= log_copying_running; - mysql_mutex_unlock(&log_sys.mutex); - stop_backup_threads(running); - mysql_mutex_lock(&log_sys.mutex); + stop_backup_threads(); } if (metadata_to_lsn && xtrabackup_copy_logfile(true)) { @@ -4532,9 +4534,8 @@ fail: if (log_copying_running) { mysql_mutex_lock(&log_sys.mutex); metadata_to_lsn = 1; - mysql_cond_broadcast(&log_copying_stop); + stop_backup_threads(); mysql_mutex_unlock(&log_sys.mutex); - stop_backup_threads(true); } log_file_op = NULL; @@ -4695,13 +4696,15 @@ reread_log_header: aligned_free(log_hdr_buf); log_copying_running = true; + + mysql_cond_init(0, &log_copying_stop, nullptr); + /* start io throttle */ - if(xtrabackup_throttle) { + if (xtrabackup_throttle) { io_ticket = xtrabackup_throttle; have_io_watching_thread = true; mysql_cond_init(0, &wait_throttle, nullptr); - mysql_thread_create(0, &io_watching_thread_id, nullptr, - io_watching_thread, nullptr); + std::thread(io_watching_thread).detach(); } /* Populate fil_system with tablespaces to copy */ @@ -4729,7 +4732,6 @@ fail_before_log_copying_thread_start: DBUG_MARIABACKUP_EVENT("before_innodb_log_copy_thread_started", {}); - mysql_cond_init(0, &log_copying_stop, nullptr); std::thread(log_copying_thread).detach(); /* FLUSH CHANGED_PAGE_BITMAPS call */ -- cgit v1.2.1 From 6710fe4b42a0909072ff8b9fb243e73bcf740ffb Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 26 Dec 2022 08:23:16 +0100 Subject: MDEV-30293: mariabackup fail with --galera-info option without Galera Without Galera, mariabackup should ignore the --galera-info option and not fail with rc != 0 like it does now. This commit fixes this flaw. --- extra/mariabackup/backup_copy.cc | 2 -- extra/mariabackup/backup_mysql.cc | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'extra/mariabackup') diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index b1655c95998..23ade2a46be 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1544,8 +1544,6 @@ bool backup_start(CorruptedPages &corrupted_pages) if (!write_galera_info(mysql_connection)) { return(false); } - // copied from xtrabackup. what is it needed for here? - write_current_binlog_file(mysql_connection); } if (opt_binlog_info == BINLOG_INFO_ON) { diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 05fc01305b7..b646bbd4ffe 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -1558,14 +1558,18 @@ write_galera_info(MYSQL *connection) if ((state_uuid == NULL && state_uuid55 == NULL) || (last_committed == NULL && last_committed55 == NULL)) { - msg("Failed to get master wsrep state from SHOW STATUS."); - result = false; + msg("Warning: failed to get master wsrep state from SHOW STATUS."); + result = true; goto cleanup; } result = backup_file_printf(XTRABACKUP_GALERA_INFO, "%s:%s\n", state_uuid ? state_uuid : state_uuid55, last_committed ? last_committed : last_committed55); + if (result) + { + write_current_binlog_file(connection); + } cleanup: free_mysql_variables(status); -- cgit v1.2.1