Commit 17e0f522 authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-27524: Incorrect binlogs after Galera SST using rsync and mariabackup

This commit adds correct handling of binlogs for SST using rsync
or mariabackup. Before this fix, binlogs were handled incorrectly -
- only one (last) binary log file was transferred during SST, which
then led to various failures (for example, when trying to list all
events from the binary log). These bugs were long masked by flaws
in the primitive binlogs handling code in the SST scripts, which
causing binary logs files to be erased after transfer or not added
to the binlog index on the joiner node. Now the correct transfer
of all binary logs (not just the last of the binary log files) has
been implemented both for the rsync (at the script level) and for
the mariabackup (at the level of the main utility code).

This commit also adds a new sst_max_binlogs=<n> parameter, which
can be located in the [sst] section or in the [xtrabackup] section
(historically, supported for mariabackup only, not for rsync), or
in one of the server sections. This parameter specifies the number
of binary log files to be sent to the joiner node during SST. This
option is added for compatibility with old SST scripting behavior,
which can be emulated by setting the sst_max_binlogs=1 (although
in general this can cause problems for the reasons described above).
In addition, setting the sst_max_binlogs=0 can be used to suppress
the transmission of binary logs to the joiner nodes during SST
(although sometimes a single file with the current binary log can
still be transmitted to the joiner, even with sst_max_binlogs=0,
because this sometimes necessary in modes that involve the use of
GTIDs with Galera).

Also, this commit ensures correct handling of paths to various
innodb files and directories in the SST scripts, and fixes some
problems with this that existed in mariabackup utility (which
were associated with incorrect handling of the innodb_data_dir
parameter in some scenarios).

In addition, this commit contains the following enhancements:

 1) Added tests for mtr, which check the correct work with binlogs
    after SST (using rsync and mariabackup);
 2) Added correct handling of slashes at the end of all paths that
    the SST script receives as parameters;
 3) Improved parsing code for --mysqld-args parameters. Now it
    correctly processes the sequence "--" after the name of the
    one-letter option;
 4) Checking the secret signature during joiner authentication
    is made independent of presence of bash (as a unix shell)
    in the system and diff utility no longer needed to check
    certificates compliance;
 5) All directories that are necessary for the correct placement
    of various logs are automatically created by SST scripts in
    advance (before running mariabackup on the joiner node);
 6) Removal of old binary logs on joiner is done using the binlog
    index (if it exists) (not only by fixed pattern that based
    on the current binlog name, as before);
 7) Paths for placing binary logs are correctly processed if they
    are set as relative paths (to the datadir);
 8) SST scripts are made even more resistant to spaces in filenames
    (now for binlogs);
 9) In case of failure, SST scripts now always end with an exit
    code other than zero;
10) SST script for rsync now correctly create a tar file with
    the binlogs, even if the paths to them (in the binlog index
    file) are specified as a mix of absolute and relative paths,
    and even if they do not match with the datadir path specified
    in the current configuration settings.
parent 571eb9d7
...@@ -582,7 +582,6 @@ datafile_read(datafile_cur_t *cursor) ...@@ -582,7 +582,6 @@ datafile_read(datafile_cur_t *cursor)
Check to see if a file exists. Check to see if a file exists.
Takes name of the file to check. Takes name of the file to check.
@return true if file exists. */ @return true if file exists. */
static
bool bool
file_exists(const char *filename) file_exists(const char *filename)
{ {
...@@ -1547,13 +1546,14 @@ bool backup_start(CorruptedPages &corrupted_pages) ...@@ -1547,13 +1546,14 @@ bool backup_start(CorruptedPages &corrupted_pages)
if (!write_galera_info(mysql_connection)) { if (!write_galera_info(mysql_connection)) {
return(false); return(false);
} }
write_current_binlog_file(mysql_connection);
} }
if (opt_binlog_info == BINLOG_INFO_ON) { bool with_binlogs = opt_binlog_info == BINLOG_INFO_ON;
lock_binlog_maybe(mysql_connection); if (with_binlogs || opt_galera_info) {
write_binlog_info(mysql_connection); if (!write_current_binlog_file(mysql_connection, with_binlogs)) {
return(false);
}
} }
if (have_flush_engine_logs && !opt_no_lock) { if (have_flush_engine_logs && !opt_no_lock) {
...@@ -1587,15 +1587,34 @@ void backup_release() ...@@ -1587,15 +1587,34 @@ void backup_release()
} }
} }
static const char *default_buffer_pool_file = "ib_buffer_pool";
static
const char * get_buffer_pool_filename(size_t *length)
{
/* If mariabackup is run for Galera, then the file
name is changed to the default so that the receiving
node can find this file and rename it according to its
settings, otherwise we keep the original file name: */
size_t dir_length = 0;
const char *dst_name = default_buffer_pool_file;
if (!opt_galera_info) {
dir_length = dirname_length(buffer_pool_filename);
dst_name = buffer_pool_filename + dir_length;
}
if (length) {
*length=dir_length;
}
return dst_name;
}
/** Finish after backup_start() and backup_release() */ /** Finish after backup_start() and backup_release() */
bool backup_finish() bool backup_finish()
{ {
/* Copy buffer pool dump or LRU dump */ /* Copy buffer pool dump or LRU dump */
if (!opt_rsync) { if (!opt_rsync) {
if (buffer_pool_filename && file_exists(buffer_pool_filename)) { if (buffer_pool_filename && file_exists(buffer_pool_filename)) {
const char *dst_name; const char *dst_name = get_buffer_pool_filename(NULL);
dst_name = trim_dotslash(buffer_pool_filename);
copy_file(ds_data, buffer_pool_filename, dst_name, 0); copy_file(ds_data, buffer_pool_filename, dst_name, 0);
} }
if (file_exists("ib_lru_dump")) { if (file_exists("ib_lru_dump")) {
...@@ -1684,17 +1703,14 @@ ibx_copy_incremental_over_full() ...@@ -1684,17 +1703,14 @@ ibx_copy_incremental_over_full()
/* copy buffer pool dump */ /* copy buffer pool dump */
if (innobase_buffer_pool_filename) { if (innobase_buffer_pool_filename) {
const char *src_name; const char *src_name = get_buffer_pool_filename(NULL);
src_name = trim_dotslash(innobase_buffer_pool_filename);
snprintf(path, sizeof(path), "%s/%s", snprintf(path, sizeof(path), "%s/%s",
xtrabackup_incremental_dir, xtrabackup_incremental_dir,
src_name); src_name);
if (file_exists(path)) { if (file_exists(path)) {
copy_file(ds_data, path, copy_file(ds_data, path, src_name, 0);
innobase_buffer_pool_filename, 0);
} }
} }
...@@ -1929,6 +1945,14 @@ copy_back() ...@@ -1929,6 +1945,14 @@ copy_back()
datadir_node_init(&node); datadir_node_init(&node);
/* If mariabackup is run for Galera, then the file
name is changed to the default so that the receiving
node can find this file and rename it according to its
settings, otherwise we keep the original file name: */
size_t dir_length;
const char *src_buffer_pool;
src_buffer_pool = get_buffer_pool_filename(&dir_length);
while (datadir_iter_next(it, &node)) { while (datadir_iter_next(it, &node)) {
const char *ext_list[] = {"backup-my.cnf", const char *ext_list[] = {"backup-my.cnf",
"xtrabackup_binary", "xtrabackup_binlog_info", "xtrabackup_binary", "xtrabackup_binlog_info",
...@@ -1991,6 +2015,11 @@ copy_back() ...@@ -1991,6 +2015,11 @@ copy_back()
continue; continue;
} }
/* skip buffer pool dump */
if (!strcmp(filename, src_buffer_pool)) {
continue;
}
/* skip innodb data files */ /* skip innodb data files */
is_ibdata_file = false; is_ibdata_file = false;
for (Tablespace::const_iterator iter(srv_sys_space.begin()), for (Tablespace::const_iterator iter(srv_sys_space.begin()),
...@@ -2013,23 +2042,18 @@ copy_back() ...@@ -2013,23 +2042,18 @@ copy_back()
/* copy buffer pool dump */ /* copy buffer pool dump */
if (innobase_buffer_pool_filename) { if (file_exists(src_buffer_pool)) {
const char *src_name; char dst_dir[FN_REFLEN];
char path[FN_REFLEN]; while (IS_TRAILING_SLASH(buffer_pool_filename, dir_length)) {
dir_length--;
src_name = trim_dotslash(innobase_buffer_pool_filename); }
memcpy(dst_dir, buffer_pool_filename, dir_length);
snprintf(path, sizeof(path), "%s/%s", dst_dir[dir_length] = 0;
mysql_data_home, if (!(ret = copy_or_move_file(src_buffer_pool,
src_name); src_buffer_pool,
dst_dir, 1)))
/* could be already copied with other files {
from data directory */ goto cleanup;
if (file_exists(src_name) &&
!file_exists(innobase_buffer_pool_filename)) {
copy_or_move_file(src_name,
innobase_buffer_pool_filename,
mysql_data_home, 0);
} }
} }
......
...@@ -32,6 +32,13 @@ copy_file(ds_ctxt_t *datasink, ...@@ -32,6 +32,13 @@ copy_file(ds_ctxt_t *datasink,
const char *dst_file_path, const char *dst_file_path,
uint thread_n); uint thread_n);
/************************************************************************
Check to see if a file exists.
Takes name of the file to check.
@return true if file exists. */
bool
file_exists(const char *filename);
/** Start --backup */ /** Start --backup */
bool backup_start(CorruptedPages &corrupted_pages); bool backup_start(CorruptedPages &corrupted_pages);
/** Release resources after backup_start() */ /** Release resources after backup_start() */
......
...@@ -83,7 +83,6 @@ os_event_t kill_query_thread_stop; ...@@ -83,7 +83,6 @@ os_event_t kill_query_thread_stop;
bool sql_thread_started = false; bool sql_thread_started = false;
char *mysql_slave_position = NULL; char *mysql_slave_position = NULL;
char *mysql_binlog_position = NULL; char *mysql_binlog_position = NULL;
char *buffer_pool_filename = NULL;
/* History on server */ /* History on server */
time_t history_start_time; time_t history_start_time;
...@@ -1333,27 +1332,29 @@ write_galera_info(MYSQL *connection) ...@@ -1333,27 +1332,29 @@ write_galera_info(MYSQL *connection)
} }
static
bool
write_binlog_info(MYSQL *connection, char *log_bin_dir,
MYSQL_RES *mysql_result, my_ulonglong n_rows,
my_ulonglong start);
/*********************************************************************//** /*********************************************************************//**
Flush and copy the current binary log file into the backup, Flush and copy the current binary log file into the backup,
if GTID is enabled */ if GTID is enabled */
bool bool
write_current_binlog_file(MYSQL *connection) write_current_binlog_file(MYSQL *connection, bool write_binlogs)
{ {
char *log_bin = NULL;
char *filename = NULL;
char *position = NULL;
char *executed_gtid_set = NULL; char *executed_gtid_set = NULL;
char *gtid_binlog_state = NULL; char *gtid_binlog_state = NULL;
char *log_bin_file = NULL;
char *log_bin_dir = NULL; char *log_bin_dir = NULL;
bool gtid_exists; bool gtid_exists;
bool result = true; bool result = true;
char filepath[FN_REFLEN];
mysql_variable status[] = { mysql_variable log_bin_var[] = {
{"Executed_Gtid_Set", &executed_gtid_set}, {"@@GLOBAL.log_bin", &log_bin},
{NULL, NULL}
};
mysql_variable status_after_flush[] = {
{"File", &log_bin_file},
{NULL, NULL} {NULL, NULL}
}; };
...@@ -1363,21 +1364,36 @@ write_current_binlog_file(MYSQL *connection) ...@@ -1363,21 +1364,36 @@ write_current_binlog_file(MYSQL *connection)
{NULL, NULL} {NULL, NULL}
}; };
read_mysql_variables(connection, "SHOW MASTER STATUS", status, false); mysql_variable status[] = {
read_mysql_variables(connection, "SHOW VARIABLES", vars, true); {"File", &filename},
{"Position", &position},
{"Executed_Gtid_Set", &executed_gtid_set},
{NULL, NULL}
};
gtid_exists = (executed_gtid_set && *executed_gtid_set) read_mysql_variables(connection, "SELECT @@GLOBAL.log_bin", log_bin_var, false);
|| (gtid_binlog_state && *gtid_binlog_state);
if (gtid_exists) { /* Do not create xtrabackup_binlog_info if binary log is disabled: */
size_t log_bin_dir_length; if (strncmp(log_bin, "1", 2) != 0) {
goto binlog_disabled;
}
lock_binlog_maybe(connection); lock_binlog_maybe(connection);
xb_mysql_query(connection, "FLUSH BINARY LOGS", false); read_mysql_variables(connection, "SHOW MASTER STATUS", status, false);
read_mysql_variables(connection, "SHOW MASTER STATUS", /* Do not create xtrabackup_binlog_info if replication
status_after_flush, false); has not started yet: */
if (filename == NULL || position == NULL) {
goto no_replication;
}
read_mysql_variables(connection, "SHOW VARIABLES", vars, true);
gtid_exists = (executed_gtid_set && *executed_gtid_set)
|| (gtid_binlog_state && *gtid_binlog_state);
if (write_binlogs || gtid_exists) {
if (opt_log_bin != NULL && strchr(opt_log_bin, FN_LIBCHAR)) { if (opt_log_bin != NULL && strchr(opt_log_bin, FN_LIBCHAR)) {
/* If log_bin is set, it has priority */ /* If log_bin is set, it has priority */
...@@ -1387,34 +1403,89 @@ write_current_binlog_file(MYSQL *connection) ...@@ -1387,34 +1403,89 @@ write_current_binlog_file(MYSQL *connection)
log_bin_dir = strdup(opt_log_bin); log_bin_dir = strdup(opt_log_bin);
} else if (log_bin_dir == NULL) { } else if (log_bin_dir == NULL) {
/* Default location is MySQL datadir */ /* Default location is MySQL datadir */
log_bin_dir = strdup("./"); log_bin_dir = static_cast<char*>(malloc(3));
ut_a(log_bin_dir);
log_bin_dir[0] = '.';
log_bin_dir[1] = FN_LIBCHAR;
log_bin_dir[2] = 0;
} }
size_t log_bin_dir_length;
dirname_part(log_bin_dir, log_bin_dir, &log_bin_dir_length); dirname_part(log_bin_dir, log_bin_dir, &log_bin_dir_length);
/* strip final slash if it is not the only path component */ /* strip final slash if it is not the only path component */
if (log_bin_dir_length > 1 && while (IS_TRAILING_SLASH(log_bin_dir, log_bin_dir_length)) {
log_bin_dir[log_bin_dir_length - 1] == FN_LIBCHAR) { log_bin_dir_length--;
log_bin_dir[log_bin_dir_length - 1] = 0;
} }
log_bin_dir[log_bin_dir_length] = 0;
if (log_bin_dir == NULL || log_bin_file == NULL) { if (log_bin_dir == NULL) {
msg("Failed to get master binlog coordinates from " msg("Failed to locate binary log files");
"SHOW MASTER STATUS");
result = false; result = false;
goto cleanup; goto cleanup;
} }
uint max_binlogs;
max_binlogs = opt_max_binlogs;
if (max_binlogs == 0) {
if (gtid_exists) {
max_binlogs = 1;
} else {
goto cleanup;
}
}
xb_mysql_query(connection, "FLUSH BINARY LOGS", false);
MYSQL_RES *mysql_result;
mysql_result = xb_mysql_query(connection, "SHOW BINARY LOGS", true);
ut_ad(mysql_num_fields(mysql_result) >= 2);
my_ulonglong n_rows;
my_ulonglong start;
n_rows = mysql_num_rows(mysql_result);
start = 0;
if (max_binlogs < n_rows) {
start = n_rows - max_binlogs;
}
if (start) {
mysql_data_seek(mysql_result, start);
}
MYSQL_ROW row;
while ((row = mysql_fetch_row(mysql_result))) {
const char *binlog_name = row[0];
char filepath[FN_REFLEN];
snprintf(filepath, sizeof(filepath), "%s%c%s", snprintf(filepath, sizeof(filepath), "%s%c%s",
log_bin_dir, FN_LIBCHAR, log_bin_file); log_bin_dir, FN_LIBCHAR, binlog_name);
result = copy_file(ds_data, filepath, log_bin_file, 0); if (file_exists(filepath)) {
result = copy_file(ds_data, filepath, binlog_name, 0);
if (!result) break;
}
}
if (result) {
write_binlog_info(connection, log_bin_dir,
mysql_result, n_rows, start);
}
mysql_free_result(mysql_result);
} }
cleanup: cleanup:
free_mysql_variables(status_after_flush);
free_mysql_variables(status);
free_mysql_variables(vars); free_mysql_variables(vars);
no_replication:
free_mysql_variables(status);
binlog_disabled:
free_mysql_variables(log_bin_var);
return(result); return(result);
} }
...@@ -1422,8 +1493,11 @@ write_current_binlog_file(MYSQL *connection) ...@@ -1422,8 +1493,11 @@ write_current_binlog_file(MYSQL *connection)
/*********************************************************************//** /*********************************************************************//**
Retrieves MySQL binlog position and Retrieves MySQL binlog position and
saves it in a file. It also prints it to stdout. */ saves it in a file. It also prints it to stdout. */
static
bool bool
write_binlog_info(MYSQL *connection) write_binlog_info(MYSQL *connection, char *log_bin_dir,
MYSQL_RES *mysql_result, my_ulonglong n_rows,
my_ulonglong start)
{ {
char *filename = NULL; char *filename = NULL;
char *position = NULL; char *position = NULL;
...@@ -1431,9 +1505,13 @@ write_binlog_info(MYSQL *connection) ...@@ -1431,9 +1505,13 @@ write_binlog_info(MYSQL *connection)
char *gtid_current_pos = NULL; char *gtid_current_pos = NULL;
char *gtid_executed = NULL; char *gtid_executed = NULL;
char *gtid = NULL; char *gtid = NULL;
bool result; char *buffer;
char *buf;
size_t total;
bool result = true;
bool mysql_gtid; bool mysql_gtid;
bool mariadb_gtid; bool mariadb_gtid;
bool with_gtid;
mysql_variable status[] = { mysql_variable status[] = {
{"File", &filename}, {"File", &filename},
...@@ -1451,39 +1529,106 @@ write_binlog_info(MYSQL *connection) ...@@ -1451,39 +1529,106 @@ write_binlog_info(MYSQL *connection)
read_mysql_variables(connection, "SHOW MASTER STATUS", status, false); read_mysql_variables(connection, "SHOW MASTER STATUS", status, false);
read_mysql_variables(connection, "SHOW VARIABLES", vars, true); read_mysql_variables(connection, "SHOW VARIABLES", vars, true);
if (filename == NULL || position == NULL) { mysql_gtid = gtid_mode && (strcmp(gtid_mode, "ON") == 0);
/* Do not create xtrabackup_binlog_info if binary mariadb_gtid = gtid_current_pos && *gtid_current_pos;
log is disabled */
result = true;
goto cleanup;
}
mysql_gtid = ((gtid_mode != NULL) && (strcmp(gtid_mode, "ON") == 0));
mariadb_gtid = (gtid_current_pos != NULL);
gtid = (gtid_executed != NULL ? gtid_executed : gtid_current_pos); gtid = (gtid_executed && *gtid_executed) ? gtid_executed : gtid_current_pos;
if (mariadb_gtid || mysql_gtid) { with_gtid = mariadb_gtid || mysql_gtid;
if (with_gtid) {
ut_a(asprintf(&mysql_binlog_position, ut_a(asprintf(&mysql_binlog_position,
"filename '%s', position '%s', " "filename '%s', position '%s', "
"GTID of the last change '%s'", "GTID of the last change '%s'",
filename, position, gtid) != -1); filename, position, gtid) != -1);
result = backup_file_printf(XTRABACKUP_BINLOG_INFO,
"%s\t%s\t%s\n", filename, position,
gtid);
} else { } else {
ut_a(asprintf(&mysql_binlog_position, ut_a(asprintf(&mysql_binlog_position,
"filename '%s', position '%s'", "filename '%s', position '%s'",
filename, position) != -1); filename, position) != -1);
result = backup_file_printf(XTRABACKUP_BINLOG_INFO,
"%s\t%s\n", filename, position);
} }
mysql_data_seek(mysql_result, start);
MYSQL_ROW row;
my_ulonglong current;
total = 1;
current = start;
while ((row = mysql_fetch_row(mysql_result))) {
const char *binlog_name = row[0];
/* The position in the current binlog is taken from
the global variable, but for the previous ones it is
determined by their length: */
const char *binlog_pos =
++current == n_rows ? position : row[1];
total += strlen(binlog_name) + strlen(binlog_pos) + 2;
if (with_gtid && current != n_rows) {
/* Add the "\t[]" length to the buffer size: */
total += 3;
}
}
/* For the last of the binray log files, also add
the length of the GTID (+ one character for '\t'): */
if (with_gtid) {
total += strlen(gtid) + 1;
}
buffer = static_cast<char*>(malloc(total));
if (!buffer) {
msg("Failed to allocate memory for temporary buffer");
result = false;
goto cleanup;
}
mysql_data_seek(mysql_result, start);
buf = buffer;
current = start;
while ((row = mysql_fetch_row(mysql_result))) {
const char *binlog_name = row[0];
char filepath[FN_REFLEN];
snprintf(filepath, sizeof(filepath), "%s%c%s",
log_bin_dir, FN_LIBCHAR, binlog_name);
current++;
if (file_exists(filepath)) {
/* The position in the current binlog is taken from
the global variable, but for the previous ones it is
determined by their length: */
char *binlog_pos =
current == n_rows ? position : row[1];
int bytes;
if (with_gtid) {
bytes = snprintf(buf, total, "%s\t%s\t%s\n",
binlog_name, binlog_pos,
current == n_rows ? gtid : "[]");
} else {
bytes = snprintf(buf, total, "%s\t%s\n",
binlog_name, binlog_pos);
}
if (bytes <= 0) {
goto buffer_overflow;
}
buf += bytes;
total -= bytes;
}
}
if (buf != buffer) {
result = backup_file_printf(XTRABACKUP_BINLOG_INFO, "%s", buffer);
}
cleanup2:
free(buffer);
cleanup: cleanup:
free_mysql_variables(status);
free_mysql_variables(vars); free_mysql_variables(vars);
free_mysql_variables(status);
return(result); return(result);
buffer_overflow:
msg("Internal error: buffer overflow in the write_binlog_info()");
result = false;
goto cleanup2;
} }
struct escape_and_quote struct escape_and_quote
...@@ -1811,7 +1956,6 @@ backup_cleanup() ...@@ -1811,7 +1956,6 @@ backup_cleanup()
{ {
free(mysql_slave_position); free(mysql_slave_position);
free(mysql_binlog_position); free(mysql_binlog_position);
free(buffer_pool_filename);
if (mysql_connection) { if (mysql_connection) {
mysql_close(mysql_connection); mysql_close(mysql_connection);
......
...@@ -28,7 +28,6 @@ extern time_t history_lock_time; ...@@ -28,7 +28,6 @@ extern time_t history_lock_time;
extern bool sql_thread_started; extern bool sql_thread_started;
extern char *mysql_slave_position; extern char *mysql_slave_position;
extern char *mysql_binlog_position; extern char *mysql_binlog_position;
extern char *buffer_pool_filename;
/** connection to mysql server */ /** connection to mysql server */
extern MYSQL *mysql_connection; extern MYSQL *mysql_connection;
...@@ -62,10 +61,7 @@ void ...@@ -62,10 +61,7 @@ void
unlock_all(MYSQL *connection); unlock_all(MYSQL *connection);
bool bool
write_current_binlog_file(MYSQL *connection); write_current_binlog_file(MYSQL *connection, bool write_binlogs);
bool
write_binlog_info(MYSQL *connection);
bool bool
write_xtrabackup_info(MYSQL *connection, const char * filename, bool history, write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
......
...@@ -187,4 +187,14 @@ xb_read_full(File fd, uchar *buf, size_t len) ...@@ -187,4 +187,14 @@ xb_read_full(File fd, uchar *buf, size_t len)
return tlen; return tlen;
} }
#ifdef _WIN32
#define IS_TRAILING_SLASH(name, length) \
((length) > 1 && \
(name[(length) - 1] == '/' || \
name[(length) - 1] == '\\'))
#else
#define IS_TRAILING_SLASH(name, length) \
((length) > 1 && name[(length) - 1] == FN_LIBCHAR)
#endif
#endif #endif
...@@ -240,7 +240,8 @@ long innobase_log_buffer_size = 1024*1024L; ...@@ -240,7 +240,8 @@ long innobase_log_buffer_size = 1024*1024L;
long innobase_open_files = 300L; long innobase_open_files = 300L;
longlong innobase_page_size = (1LL << 14); /* 16KB */ longlong innobase_page_size = (1LL << 14); /* 16KB */
char* innobase_buffer_pool_filename = NULL; char *innobase_buffer_pool_filename = NULL;
char *buffer_pool_filename = NULL;
/* The default values for the following char* start-up parameters /* The default values for the following char* start-up parameters
are determined in innobase_init below: */ are determined in innobase_init below: */
...@@ -347,6 +348,7 @@ uint opt_lock_wait_timeout = 0; ...@@ -347,6 +348,7 @@ uint opt_lock_wait_timeout = 0;
uint opt_lock_wait_threshold = 0; uint opt_lock_wait_threshold = 0;
uint opt_debug_sleep_before_unlock = 0; uint opt_debug_sleep_before_unlock = 0;
uint opt_safe_slave_backup_timeout = 0; uint opt_safe_slave_backup_timeout = 0;
uint opt_max_binlogs = UINT_MAX;
const char *opt_history = NULL; const char *opt_history = NULL;
...@@ -1051,7 +1053,8 @@ enum options_xtrabackup ...@@ -1051,7 +1053,8 @@ enum options_xtrabackup
OPT_BACKUP_ROCKSDB, OPT_BACKUP_ROCKSDB,
OPT_XTRA_CHECK_PRIVILEGES, OPT_XTRA_CHECK_PRIVILEGES,
OPT_XB_IGNORE_INNODB_PAGE_CORRUPTION, OPT_XB_IGNORE_INNODB_PAGE_CORRUPTION,
OPT_INNODB_FORCE_RECOVERY OPT_INNODB_FORCE_RECOVERY,
OPT_MAX_BINLOGS
}; };
struct my_option xb_client_options[]= { struct my_option xb_client_options[]= {
...@@ -1454,6 +1457,17 @@ struct my_option xb_client_options[]= { ...@@ -1454,6 +1457,17 @@ struct my_option xb_client_options[]= {
&opt_log_innodb_page_corruption, &opt_log_innodb_page_corruption, 0, &opt_log_innodb_page_corruption, &opt_log_innodb_page_corruption, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"sst_max_binlogs", OPT_MAX_BINLOGS,
"Number of recent binary logs to be included in the backup. "
"Setting this parameter to zero normally disables transmission "
"of binary logs to the joiner nodes during SST using Galera. "
"But sometimes a single current binlog can still be transmitted "
"to the joiner even with sst_max_binlogs=0, because it is "
"required for Galera to work properly with GTIDs support.",
(G_PTR *) &opt_max_binlogs,
(G_PTR *) &opt_max_binlogs, 0, GET_UINT, OPT_ARG,
UINT_MAX, 0, UINT_MAX, 0, 1, 0},
#define MYSQL_CLIENT #define MYSQL_CLIENT
#include "sslopt-longopts.h" #include "sslopt-longopts.h"
#undef MYSQL_CLIENT #undef MYSQL_CLIENT
...@@ -6272,6 +6286,44 @@ check_all_privileges() ...@@ -6272,6 +6286,44 @@ check_all_privileges()
} }
} }
static
void
xb_init_buffer_pool(const char * filename)
{
if (filename &&
#ifdef _WIN32
(filename[0] == '/' ||
filename[0] == '\\' ||
strchr(filename, ':')))
#else
filename[0] == FN_LIBCHAR)
#endif
{
buffer_pool_filename = strdup(filename);
} else {
char filepath[FN_REFLEN];
char *dst_dir =
(innobase_data_home_dir && *innobase_data_home_dir) ?
innobase_data_home_dir : mysql_data_home;
size_t dir_length;
if (dst_dir && *dst_dir) {
dir_length = strlen(dst_dir);
while (IS_TRAILING_SLASH(dst_dir, dir_length)) {
dir_length--;
}
memcpy(filepath, dst_dir, dir_length);
}
else {
filepath[0] = '.';
dir_length = 1;
}
snprintf(filepath + dir_length,
sizeof(filepath) - dir_length, "%c%s", FN_LIBCHAR,
filename ? filename : "ib_buffer_pool");
buffer_pool_filename = strdup(filepath);
}
}
bool bool
xb_init() xb_init()
{ {
...@@ -6336,11 +6388,15 @@ xb_init() ...@@ -6336,11 +6388,15 @@ xb_init()
if (!get_mysql_vars(mysql_connection)) { if (!get_mysql_vars(mysql_connection)) {
return(false); return(false);
} }
xb_init_buffer_pool(buffer_pool_filename);
if (opt_check_privileges) { if (opt_check_privileges) {
check_all_privileges(); check_all_privileges();
} }
history_start_time = time(NULL); history_start_time = time(NULL);
} else {
xb_init_buffer_pool(innobase_buffer_pool_filename);
} }
return(true); return(true);
...@@ -6634,6 +6690,8 @@ int main(int argc, char **argv) ...@@ -6634,6 +6690,8 @@ int main(int argc, char **argv)
free_error_messages(); free_error_messages();
mysql_mutex_destroy(&LOCK_error_log); mysql_mutex_destroy(&LOCK_error_log);
free(buffer_pool_filename);
if (status == EXIT_SUCCESS) { if (status == EXIT_SUCCESS) {
msg("completed OK!"); msg("completed OK!");
} }
......
...@@ -69,6 +69,7 @@ extern char *xtrabackup_incremental_dir; ...@@ -69,6 +69,7 @@ extern char *xtrabackup_incremental_dir;
extern char *xtrabackup_incremental_basedir; extern char *xtrabackup_incremental_basedir;
extern char *innobase_data_home_dir; extern char *innobase_data_home_dir;
extern char *innobase_buffer_pool_filename; extern char *innobase_buffer_pool_filename;
extern char *buffer_pool_filename;
extern char *xb_plugin_dir; extern char *xb_plugin_dir;
extern char *xb_rocksdb_datadir; extern char *xb_rocksdb_datadir;
extern my_bool xb_backup_rocksdb; extern my_bool xb_backup_rocksdb;
...@@ -164,6 +165,7 @@ extern uint opt_lock_wait_timeout; ...@@ -164,6 +165,7 @@ extern uint opt_lock_wait_timeout;
extern uint opt_lock_wait_threshold; extern uint opt_lock_wait_threshold;
extern uint opt_debug_sleep_before_unlock; extern uint opt_debug_sleep_before_unlock;
extern uint opt_safe_slave_backup_timeout; extern uint opt_safe_slave_backup_timeout;
extern uint opt_max_binlogs;
extern const char *opt_history; extern const char *opt_history;
......
--echo Performing --wsrep-recover ... --echo Performing --wsrep-recover ...
if ($wsrep_recover_additional)
{
--exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover $wsrep_recover_additional > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1
}
if (!$wsrep_recover_additional)
{
--exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1 --exec $MYSQLD --defaults-group-suffix=.$galera_wsrep_recover_server_id --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1
}
--perl --perl
use strict; use strict;
......
connection node_1; connection node_1;
connection node_2;
connection node_1;
reset master; reset master;
connection node_2; connection node_2;
reset master; reset master;
...@@ -40,6 +42,12 @@ hostname1-bin.000001 # Xid # # COMMIT /* XID */ ...@@ -40,6 +42,12 @@ hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-# hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
connection node_2; connection node_2;
Shutting down server ...
connection node_1;
Cleaning var directory ...
connection node_2;
Starting server ...
connection node_2;
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
COUNT(*) = 2 COUNT(*) = 2
1 1
...@@ -66,6 +74,7 @@ hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F ...@@ -66,6 +74,7 @@ hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */ hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-# hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
hostname1-bin.000001 # Rotate # # hostname1-bin.000002;pos=4
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
#cleanup #cleanup
......
connection node_1;
connection node_2;
connection node_1;
reset master;
connection node_2;
reset master;
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);
connection node_2;
SELECT COUNT(*) = 1 FROM t1;
COUNT(*) = 1
1
SELECT COUNT(*) = 2 FROM t2;
COUNT(*) = 2
1
connection node_1;
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
connection node_2;
Shutting down server ...
connection node_1;
Cleaning var directory ...
connection node_2;
Starting server ...
connection node_2;
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
COUNT(*) = 2
1
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t1)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT) ENGINE=InnoDB
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # BEGIN GTID #-#-#
hostname1-bin.000001 # Annotate_rows # # INSERT INTO t2 VALUES (1)
hostname1-bin.000001 # Table_map # # table_id: # (test.t2)
hostname1-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
hostname1-bin.000001 # Xid # # COMMIT /* XID */
hostname1-bin.000001 # Gtid # # GTID #-#-#
hostname1-bin.000001 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN f2 INTEGER
hostname1-bin.000001 # Rotate # # hostname1-bin.000002;pos=4
DROP TABLE t1;
DROP TABLE t2;
#cleanup
connection node_1;
RESET MASTER;
--- galera_sst_rsync.result --- galera_sst_rsync.result
+++ galera_sst_rsync,debug.reject +++ galera_sst_rsync.reject
@@ -284,3 +284,111 @@ @@ -286,3 +286,111 @@
DROP TABLE t1; DROP TABLE t1;
COMMIT; COMMIT;
SET AUTOCOMMIT=ON; SET AUTOCOMMIT=ON;
......
--- suite/galera/r/galera_sst_rsync2.result 2018-09-12 13:09:35.352229478 +0200 --- suite/galera/r/galera_sst_rsync2.result
+++ suite/galera/r/galera_sst_rsync2,debug.reject 2018-09-12 17:00:51.601974979 +0200 +++ suite/galera/r/galera_sst_rsync2.reject
@@ -286,3 +286,111 @@ @@ -286,3 +286,111 @@
DROP TABLE t1; DROP TABLE t1;
COMMIT; COMMIT;
......
--- galera_sst_mariabackup.result --- galera_sst_xtrabackup-v2.result
+++ galera_sst_mariabackup,debug.reject +++ galera_sst_xtrabackup-v2.reject
@@ -286,5 +286,113 @@ @@ -286,5 +286,113 @@
DROP TABLE t1; DROP TABLE t1;
COMMIT; COMMIT;
......
--- r/galera_sst_xtrabackup-v2_data_dir.result 2018-11-19 12:27:24.795221479 +0200 --- galera_sst_xtrabackup-v2_data_dir.result
+++ r/galera_sst_xtrabackup-v2_data_dir.reject 2018-11-19 19:15:38.774008404 +0200 +++ galera_sst_xtrabackup-v2_data_dir.reject
@@ -260,3 +260,100 @@ @@ -286,5 +286,113 @@
DROP TABLE t1; DROP TABLE t1;
COMMIT; COMMIT;
SET AUTOCOMMIT=ON; SET AUTOCOMMIT=ON;
+Performing State Transfer on a server that has been killed and restarted +Performing State Transfer on a server that has been killed and restarted
+while a DDL was in progress on it +while a DDL was in progress on it
+connection node_1;
+CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
+SET AUTOCOMMIT=OFF; +SET AUTOCOMMIT=OFF;
+START TRANSACTION; +START TRANSACTION;
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
+INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before');
+INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before');
+connection node_2;
+START TRANSACTION; +START TRANSACTION;
+INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before');
+INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before');
...@@ -22,9 +24,12 @@ ...@@ -22,9 +24,12 @@
+INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before');
+COMMIT; +COMMIT;
+SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; +SET GLOBAL debug_dbug = 'd,sync.alter_opened_table';
+connection node_1;
+ALTER TABLE t1 ADD COLUMN f2 INTEGER; +ALTER TABLE t1 ADD COLUMN f2 INTEGER;
+connection node_2;
+SET wsrep_sync_wait = 0; +SET wsrep_sync_wait = 0;
+Killing server ... +Killing server ...
+connection node_1;
+SET AUTOCOMMIT=OFF; +SET AUTOCOMMIT=OFF;
+START TRANSACTION; +START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_committed_during'); +INSERT INTO t1 (f1) VALUES ('node1_committed_during');
...@@ -39,6 +44,7 @@ ...@@ -39,6 +44,7 @@
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1;
+SET AUTOCOMMIT=OFF; +SET AUTOCOMMIT=OFF;
+START TRANSACTION; +START TRANSACTION;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
...@@ -46,7 +52,9 @@ ...@@ -46,7 +52,9 @@
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+connection node_2;
+Performing --wsrep-recover ... +Performing --wsrep-recover ...
+connection node_2;
+Starting server ... +Starting server ...
+Using --wsrep-start-position when starting mysqld ... +Using --wsrep-start-position when starting mysqld ...
+SET AUTOCOMMIT=OFF; +SET AUTOCOMMIT=OFF;
...@@ -57,6 +65,7 @@ ...@@ -57,6 +65,7 @@
+INSERT INTO t1 (f1) VALUES ('node2_committed_after'); +INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+INSERT INTO t1 (f1) VALUES ('node2_committed_after'); +INSERT INTO t1 (f1) VALUES ('node2_committed_after');
+COMMIT; +COMMIT;
+connection node_1;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after');
...@@ -71,6 +80,7 @@ ...@@ -71,6 +80,7 @@
+INSERT INTO t1 (f1) VALUES ('node1_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+INSERT INTO t1 (f1) VALUES ('node1_committed_after'); +INSERT INTO t1 (f1) VALUES ('node1_committed_after');
+COMMIT; +COMMIT;
+connection node_1a_galera_st_kill_slave_ddl;
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
+INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after');
...@@ -88,6 +98,7 @@ ...@@ -88,6 +98,7 @@
+1 +1
+COMMIT; +COMMIT;
+SET AUTOCOMMIT=ON; +SET AUTOCOMMIT=ON;
+connection node_1;
+SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; +SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
+COUNT(*) = 2 +COUNT(*) = 2
+1 +1
...@@ -101,3 +112,5 @@ ...@@ -101,3 +112,5 @@
+COMMIT; +COMMIT;
+SET AUTOCOMMIT=ON; +SET AUTOCOMMIT=ON;
+SET GLOBAL debug_dbug = $debug_orig; +SET GLOBAL debug_dbug = $debug_orig;
disconnect node_2;
disconnect node_1;
...@@ -286,3 +286,5 @@ COUNT(*) = 0 ...@@ -286,3 +286,5 @@ COUNT(*) = 0
DROP TABLE t1; DROP TABLE t1;
COMMIT; COMMIT;
SET AUTOCOMMIT=ON; SET AUTOCOMMIT=ON;
disconnect node_2;
disconnect node_1;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4;
connection node_1;
connection node_2;
connection node_3;
connection node_4;
SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
EXPECT_4 EXPECT_4
4 4
...@@ -6,10 +12,8 @@ CREATE TABLE t1 (f1 INTEGER); ...@@ -6,10 +12,8 @@ CREATE TABLE t1 (f1 INTEGER);
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
connection node_2; connection node_2;
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
connection node_3; connection node_3;
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4;
connection node_4; connection node_4;
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
connection node_3; connection node_3;
...@@ -81,3 +85,6 @@ CALL mtr.add_suppression("There are no nodes in the same segment that will ever ...@@ -81,3 +85,6 @@ CALL mtr.add_suppression("There are no nodes in the same segment that will ever
CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
connection node_4; connection node_4;
CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
connection node_1;
disconnect node_3;
disconnect node_4;
...@@ -9,3 +9,6 @@ log-slave-updates ...@@ -9,3 +9,6 @@ log-slave-updates
log-bin = hostname2-bin log-bin = hostname2-bin
log-bin-index = hostname2.bdx log-bin-index = hostname2.bdx
log-slave-updates log-slave-updates
[sst]
sst_max_binlogs=
--source galera_log_bin.inc --source galera_log_bin_sst.inc
!include ../galera_2nodes.cnf
[mysqld]
wsrep_sst_method=mariabackup
wsrep_sst_auth="root:"
[mysqld.1]
log-bin=@ENV.MYSQLTEST_VARDIR/mysqld.1/data/hostname1-bin
log-bin-index = hostname1.bdx
log-slave-updates
[mysqld.2]
log-bin=@ENV.MYSQLTEST_VARDIR/mysqld.2/data/hostname2-bin
log-bin-index = hostname2.bdx
log-slave-updates
[sst]
transferfmt=@ENV.MTR_GALERA_TFMT
sst_max_binlogs=
--source include/have_mariabackup.inc
--source galera_log_bin_sst.inc
--source include/galera_cluster.inc
--source include/force_restart.inc
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--source include/auto_increment_offset_save.inc
--connection node_1
reset master;
--connection node_2
reset master;
#
# Test Galera with --log-bin --log-slave-updates .
# This way the actual MySQL binary log is used,
# rather than Galera's own implementation
#
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (id INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1);
INSERT INTO t2 VALUES (1);
--connection node_2
SELECT COUNT(*) = 1 FROM t1;
SELECT COUNT(*) = 2 FROM t2;
--connection node_1
ALTER TABLE t1 ADD COLUMN f2 INTEGER;
--let $MASTER_MYPORT=$NODE_MYPORT_1
--source include/show_binlog_events.inc
--connection node_2
#--connection node_2
#--source suite/galera/include/galera_stop_replication.inc
--echo Shutting down server ...
--source include/shutdown_mysqld.inc
--connection node_1
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
#
# Force SST
#
--echo Cleaning var directory ...
--remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mtr
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/performance_schema
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/test
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data/mysql
--remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.2/data
--connection node_2
--echo Starting server ...
let $restart_noprint=2;
--source include/start_mysqld.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
--source include/wait_condition.inc
--connection node_2
SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1';
--let $MASTER_MYPORT=$NODE_MYPORT_2
--source include/show_binlog_events.inc
DROP TABLE t1;
DROP TABLE t2;
--echo #cleanup
--connection node_1
RESET MASTER;
# Restore original auto_increment_offset values.
--source include/auto_increment_offset_restore.inc
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
--source suite/galera/include/galera_st_kill_slave.inc --source suite/galera/include/galera_st_kill_slave.inc
--source suite/galera/include/galera_st_kill_slave_ddl.inc --source suite/galera/include/galera_st_kill_slave_ddl.inc
--source include/auto_increment_offset_restore.inc --source include/auto_increment_offset_restore.inc
...@@ -12,4 +12,3 @@ log_bin ...@@ -12,4 +12,3 @@ log_bin
wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true'
log_basename=server2 log_basename=server2
log_bin log_bin
...@@ -12,6 +12,16 @@ ...@@ -12,6 +12,16 @@
--source include/galera_cluster.inc --source include/galera_cluster.inc
--source include/force_restart.inc --source include/force_restart.inc
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--let $node_3=node_3
--let $node_4=node_4
--source include/auto_increment_offset_save.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc --source include/wait_condition.inc
SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; SELECT VARIABLE_VALUE AS EXPECT_4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
...@@ -23,11 +33,9 @@ INSERT INTO t1 VALUES (1); ...@@ -23,11 +33,9 @@ INSERT INTO t1 VALUES (1);
--connection node_2 --connection node_2
INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (2);
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connection node_3 --connection node_3
INSERT INTO t1 VALUES (3); INSERT INTO t1 VALUES (3);
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4
--connection node_4 --connection node_4
INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (4);
...@@ -156,3 +164,10 @@ CALL mtr.add_suppression("Action message in non-primary configuration from membe ...@@ -156,3 +164,10 @@ CALL mtr.add_suppression("Action message in non-primary configuration from membe
--connection node_4 --connection node_4
CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0");
# Restore original auto_increment_offset values.
--source include/auto_increment_offset_restore.inc
--connection node_1
--disconnect node_3
--disconnect node_4
This diff is collapsed.
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
set -ue set -ue
# Copyright (C) 2009-2015 Codership Oy # Copyright (C) 2009-2015 Codership Oy
# Copyright (C) 2017-2021 MariaDB # Copyright (C) 2017-2022 MariaDB
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
...@@ -40,8 +40,7 @@ then ...@@ -40,8 +40,7 @@ then
fi fi
# Check client version # Check client version
if ! $MYSQL_CLIENT --version | grep 'Distrib 10\.[1-9]' >/dev/null if ! $MYSQL_CLIENT --version | grep -q -E 'Distrib 10\.[1-9]'; then
then
$MYSQL_CLIENT --version >&2 $MYSQL_CLIENT --version >&2
wsrep_log_error "this operation requires MySQL client version 10.1 or newer" wsrep_log_error "this operation requires MySQL client version 10.1 or newer"
exit $EINVAL exit $EINVAL
...@@ -95,7 +94,7 @@ DROP PREPARE stmt;" ...@@ -95,7 +94,7 @@ DROP PREPARE stmt;"
SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';" SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';"
SET_WSREP_GTID_DOMAIN_ID="" SET_WSREP_GTID_DOMAIN_ID=""
if [ -n $WSREP_SST_OPT_GTID_DOMAIN_ID ]; then if [ -n "$WSREP_SST_OPT_GTID_DOMAIN_ID" ]; then
SET_WSREP_GTID_DOMAIN_ID=" SET_WSREP_GTID_DOMAIN_ID="
SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0); SET @val = (SELECT GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHERE VARIABLE_NAME = 'WSREP_GTID_STRICT_MODE' AND GLOBAL_VALUE > 0);
SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0'); SET @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0');
......
This diff is collapsed.
This diff is collapsed.
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