diff options
Diffstat (limited to 'extra/mariabackup')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 2 | ||||
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 8 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 58 |
3 files changed, 32 insertions, 36 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index a8959861926..07c6798a362 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1483,8 +1483,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 ea85c478997..8b9962597af 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -1444,14 +1444,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); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 3a0db1401ad..affdb4c44f3 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; @@ -2141,7 +2142,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; @@ -3093,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) { @@ -3115,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 @@ -4379,27 +4382,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 @@ -4429,11 +4434,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)) { @@ -4534,9 +4535,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; @@ -4575,7 +4575,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"); @@ -4697,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 */ @@ -4731,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 */ @@ -6030,12 +6030,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 " |