diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2020-04-20 17:23:43 +0300 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2020-04-21 10:34:37 +0300 |
commit | 0efe1971c6f0c7c2edf906372550bef234ebb8a1 (patch) | |
tree | c79fb38acaa3ca3d198f8664e15113ce3b7ac8f5 /extra | |
parent | 36bddacf6b9177587eb5364e81f42a482df7d73f (diff) | |
download | mariadb-git-0efe1971c6f0c7c2edf906372550bef234ebb8a1.tar.gz |
MDEV-19347: Mariabackup does not honor ignore_db_dirs from serverbb-10.2-MDEV-19347-ignore_db_dirs
config.
The solution is to read the system variable value on startup and to fill
databases_exclude_hash.
xb_load_list_string() became non-static and was reformatted. The system
variable value is read and processed in get_mysql_vars(), which was also
reformatted.
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 340 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 35 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.h | 10 |
3 files changed, 208 insertions, 177 deletions
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 843ebf2663e..d5d0c90376e 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -326,194 +326,212 @@ check_server_version(unsigned long version_number, /*********************************************************************//** Receive options important for XtraBackup from MySQL server. @return true on success. */ -bool -get_mysql_vars(MYSQL *connection) +bool get_mysql_vars(MYSQL *connection) { - char *gtid_mode_var = NULL; - char *version_var = NULL; - char *version_comment_var = NULL; - char *innodb_version_var = NULL; - char *have_backup_locks_var = NULL; - char *log_bin_var = NULL; - char *lock_wait_timeout_var= NULL; - char *wsrep_on_var = NULL; - char *slave_parallel_workers_var = NULL; - char *gtid_slave_pos_var = NULL; - char *innodb_buffer_pool_filename_var = NULL; - char *datadir_var = NULL; - char *innodb_log_group_home_dir_var = NULL; - char *innodb_log_file_size_var = NULL; - char *innodb_log_files_in_group_var = NULL; - char *innodb_data_file_path_var = NULL; - char *innodb_data_home_dir_var = NULL; - char *innodb_undo_directory_var = NULL; - char *innodb_page_size_var = NULL; - char *innodb_undo_tablespaces_var = NULL; - char *page_zip_level_var = NULL; - char *endptr; - unsigned long server_version = mysql_get_server_version(connection); - - bool ret = true; - - mysql_variable mysql_vars[] = { - {"have_backup_locks", &have_backup_locks_var}, - {"log_bin", &log_bin_var}, - {"lock_wait_timeout", &lock_wait_timeout_var}, - {"gtid_mode", >id_mode_var}, - {"version", &version_var}, - {"version_comment", &version_comment_var}, - {"innodb_version", &innodb_version_var}, - {"wsrep_on", &wsrep_on_var}, - {"slave_parallel_workers", &slave_parallel_workers_var}, - {"gtid_slave_pos", >id_slave_pos_var}, - {"innodb_buffer_pool_filename", - &innodb_buffer_pool_filename_var}, - {"datadir", &datadir_var}, - {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, - {"innodb_log_file_size", &innodb_log_file_size_var}, - {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, - {"innodb_data_file_path", &innodb_data_file_path_var}, - {"innodb_data_home_dir", &innodb_data_home_dir_var}, - {"innodb_undo_directory", &innodb_undo_directory_var}, - {"innodb_page_size", &innodb_page_size_var}, - {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, - {"innodb_compression_level", &page_zip_level_var}, - {NULL, NULL} - }; - - read_mysql_variables(connection, "SHOW VARIABLES", - mysql_vars, true); + char *gtid_mode_var= NULL; + char *version_var= NULL; + char *version_comment_var= NULL; + char *innodb_version_var= NULL; + char *have_backup_locks_var= NULL; + char *log_bin_var= NULL; + char *lock_wait_timeout_var= NULL; + char *wsrep_on_var= NULL; + char *slave_parallel_workers_var= NULL; + char *gtid_slave_pos_var= NULL; + char *innodb_buffer_pool_filename_var= NULL; + char *datadir_var= NULL; + char *innodb_log_group_home_dir_var= NULL; + char *innodb_log_file_size_var= NULL; + char *innodb_log_files_in_group_var= NULL; + char *innodb_data_file_path_var= NULL; + char *innodb_data_home_dir_var= NULL; + char *innodb_undo_directory_var= NULL; + char *innodb_page_size_var= NULL; + char *innodb_undo_tablespaces_var= NULL; + char *page_zip_level_var= NULL; + char *ignore_db_dirs= NULL; + char *endptr; + unsigned long server_version= mysql_get_server_version(connection); + + bool ret= true; + + mysql_variable mysql_vars[]= { + {"have_backup_locks", &have_backup_locks_var}, + {"log_bin", &log_bin_var}, + {"lock_wait_timeout", &lock_wait_timeout_var}, + {"gtid_mode", >id_mode_var}, + {"version", &version_var}, + {"version_comment", &version_comment_var}, + {"innodb_version", &innodb_version_var}, + {"wsrep_on", &wsrep_on_var}, + {"slave_parallel_workers", &slave_parallel_workers_var}, + {"gtid_slave_pos", >id_slave_pos_var}, + {"innodb_buffer_pool_filename", &innodb_buffer_pool_filename_var}, + {"datadir", &datadir_var}, + {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, + {"innodb_log_file_size", &innodb_log_file_size_var}, + {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, + {"innodb_data_file_path", &innodb_data_file_path_var}, + {"innodb_data_home_dir", &innodb_data_home_dir_var}, + {"innodb_undo_directory", &innodb_undo_directory_var}, + {"innodb_page_size", &innodb_page_size_var}, + {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, + {"innodb_compression_level", &page_zip_level_var}, + {"ignore_db_dirs", &ignore_db_dirs}, + {NULL, NULL}}; + + read_mysql_variables(connection, "SHOW VARIABLES", mysql_vars, true); + + if (have_backup_locks_var != NULL && !opt_no_backup_locks) + { + have_backup_locks= true; + } - if (have_backup_locks_var != NULL && !opt_no_backup_locks) { - have_backup_locks = true; - } + if (opt_binlog_info == BINLOG_INFO_AUTO) + { + if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) + opt_binlog_info= BINLOG_INFO_ON; + else + opt_binlog_info= BINLOG_INFO_OFF; + } - if (opt_binlog_info == BINLOG_INFO_AUTO) { - if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) - opt_binlog_info = BINLOG_INFO_ON; - else - opt_binlog_info = BINLOG_INFO_OFF; - } + if (lock_wait_timeout_var != NULL) + { + have_lock_wait_timeout= true; + } - if (lock_wait_timeout_var != NULL) { - have_lock_wait_timeout = true; - } + if (wsrep_on_var != NULL) + { + have_galera_enabled= true; + } - if (wsrep_on_var != NULL) { - have_galera_enabled = true; - } + /* Check server version compatibility and detect server flavor */ - /* Check server version compatibility and detect server flavor */ + if (!(ret= check_server_version(server_version, version_var, + version_comment_var, innodb_version_var))) + { + goto out; + } - if (!(ret = check_server_version(server_version, version_var, - version_comment_var, - innodb_version_var))) { - goto out; - } + if (server_version > 50500) + { + have_flush_engine_logs= true; + } - if (server_version > 50500) { - have_flush_engine_logs = true; - } + if (slave_parallel_workers_var != NULL && + atoi(slave_parallel_workers_var) > 0) + { + have_multi_threaded_slave= true; + } - if (slave_parallel_workers_var != NULL - && atoi(slave_parallel_workers_var) > 0) { - have_multi_threaded_slave = true; - } + if (innodb_buffer_pool_filename_var != NULL) + { + buffer_pool_filename= strdup(innodb_buffer_pool_filename_var); + } - if (innodb_buffer_pool_filename_var != NULL) { - buffer_pool_filename = strdup(innodb_buffer_pool_filename_var); - } + if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || + (gtid_slave_pos_var && *gtid_slave_pos_var)) + { + have_gtid_slave= true; + } - if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || - (gtid_slave_pos_var && *gtid_slave_pos_var)) { - have_gtid_slave = true; - } + msg("Using server version %s", version_var); - msg("Using server version %s", version_var); + if (!(ret= detect_mysql_capabilities_for_backup())) + { + goto out; + } - if (!(ret = detect_mysql_capabilities_for_backup())) { - goto out; - } + /* make sure datadir value is the same in configuration file */ + if (check_if_param_set("datadir")) + { + if (!directory_exists(mysql_data_home, false)) + { + msg("Warning: option 'datadir' points to " + "nonexistent directory '%s'", + mysql_data_home); + } + if (!directory_exists(datadir_var, false)) + { + msg("Warning: MySQL variable 'datadir' points to " + "nonexistent directory '%s'", + datadir_var); + } + if (!equal_paths(mysql_data_home, datadir_var)) + { + msg("Warning: option 'datadir' has different " + "values:\n" + " '%s' in defaults file\n" + " '%s' in SHOW VARIABLES", + mysql_data_home, datadir_var); + } + } - /* make sure datadir value is the same in configuration file */ - if (check_if_param_set("datadir")) { - if (!directory_exists(mysql_data_home, false)) { - msg("Warning: option 'datadir' points to " - "nonexistent directory '%s'", mysql_data_home); - } - if (!directory_exists(datadir_var, false)) { - msg("Warning: MySQL variable 'datadir' points to " - "nonexistent directory '%s'", datadir_var); - } - if (!equal_paths(mysql_data_home, datadir_var)) { - msg("Warning: option 'datadir' has different " - "values:\n" - " '%s' in defaults file\n" - " '%s' in SHOW VARIABLES", - mysql_data_home, datadir_var); - } - } + /* get some default values is they are missing from my.cnf */ + if (datadir_var && *datadir_var) + { + strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); + mysql_data_home= mysql_real_data_home; + } - /* get some default values is they are missing from my.cnf */ - if (datadir_var && *datadir_var) { - strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); - mysql_data_home= mysql_real_data_home; - } + if (innodb_data_file_path_var && *innodb_data_file_path_var) + { + innobase_data_file_path= my_strdup(innodb_data_file_path_var, MYF(MY_FAE)); + } - if (innodb_data_file_path_var && *innodb_data_file_path_var) { - innobase_data_file_path = my_strdup( - innodb_data_file_path_var, MYF(MY_FAE)); - } + if (innodb_data_home_dir_var) + { + innobase_data_home_dir= my_strdup(innodb_data_home_dir_var, MYF(MY_FAE)); + } - if (innodb_data_home_dir_var) { - innobase_data_home_dir = my_strdup( - innodb_data_home_dir_var, MYF(MY_FAE)); - } + if (innodb_log_group_home_dir_var && *innodb_log_group_home_dir_var) + { + srv_log_group_home_dir= + my_strdup(innodb_log_group_home_dir_var, MYF(MY_FAE)); + } - if (innodb_log_group_home_dir_var - && *innodb_log_group_home_dir_var) { - srv_log_group_home_dir = my_strdup( - innodb_log_group_home_dir_var, MYF(MY_FAE)); - } + if (innodb_undo_directory_var && *innodb_undo_directory_var) + { + srv_undo_dir= my_strdup(innodb_undo_directory_var, MYF(MY_FAE)); + } - if (innodb_undo_directory_var && *innodb_undo_directory_var) { - srv_undo_dir = my_strdup( - innodb_undo_directory_var, MYF(MY_FAE)); - } + if (innodb_log_files_in_group_var) + { + srv_n_log_files= strtol(innodb_log_files_in_group_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_files_in_group_var) { - srv_n_log_files = strtol( - innodb_log_files_in_group_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_log_file_size_var) + { + srv_log_file_size= strtoll(innodb_log_file_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_file_size_var) { - srv_log_file_size = strtoll( - innodb_log_file_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_page_size_var) + { + innobase_page_size= strtoll(innodb_page_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_page_size_var) { - innobase_page_size = strtoll( - innodb_page_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_undo_tablespaces_var) + { + srv_undo_tablespaces= strtoul(innodb_undo_tablespaces_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_undo_tablespaces_var) { - srv_undo_tablespaces = strtoul(innodb_undo_tablespaces_var, - &endptr, 10); - ut_ad(*endptr == 0); - } + if (page_zip_level_var != NULL) + { + page_zip_level= strtoul(page_zip_level_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (page_zip_level_var != NULL) { - page_zip_level = strtoul(page_zip_level_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (ignore_db_dirs) + xb_load_list_string(ignore_db_dirs, ",", register_ignore_db_dirs_filter); out: - free_mysql_variables(mysql_vars); + free_mysql_variables(mysql_vars); - return(ret); + return (ret); } /*********************************************************************//** diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index d11f7295f8e..040fbeb8f32 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3632,6 +3632,11 @@ xb_register_exclude_filter_entry( &tables_exclude_hash); } +void register_ignore_db_dirs_filter(const char *name) +{ + xb_add_filter(name, &databases_exclude_hash); +} + /*********************************************************************** Register new table for the filter. */ static @@ -3694,26 +3699,24 @@ xb_register_exclude_regex( typedef void (*insert_entry_func_t)(const char*); -/*********************************************************************** -Scan string and load filter entries from it. */ -static -void -xb_load_list_string( -/*================*/ - char* list, /*!< in: string representing a list */ - const char* delimiters, /*!< in: delimiters of entries */ - insert_entry_func_t ins) /*!< in: callback to add entry */ +/* Scan string and load filter entries from it. +@param[in] list string representing a list +@param[in] delimiters delimiters of entries +@param[in] ins callback to add entry */ +void xb_load_list_string(char *list, const char *delimiters, + insert_entry_func_t ins) { - char* p; - char* saveptr; + char *p; + char *saveptr; - p = strtok_r(list, delimiters, &saveptr); - while (p) { + p= strtok_r(list, delimiters, &saveptr); + while (p) + { - ins(p); + ins(p); - p = strtok_r(NULL, delimiters, &saveptr); - } + p= strtok_r(NULL, delimiters, &saveptr); + } } /*********************************************************************** diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index c56e83f7a32..2dbdd442f95 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -194,4 +194,14 @@ void mdl_lock_init(); void mdl_lock_table(ulint space_id); void mdl_unlock_all(); bool ends_with(const char *str, const char *suffix); + +typedef void (*insert_entry_func_t)(const char*); + +/* Scan string and load filter entries from it. +@param[in] list string representing a list +@param[in] delimiters delimiters of entries +@param[in] ins callback to add entry */ +void xb_load_list_string(char *list, const char *delimiters, + insert_entry_func_t ins); +void register_ignore_db_dirs_filter(const char *name); #endif /* XB_XTRABACKUP_H */ |