Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 8 additions & 84 deletions extra/mariabackup/backup_mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,14 @@ write_galera_info(ds_ctxt *datasink, MYSQL *connection)
domain_id ? domain_id : domain_id55);
}

if (result)
write_current_binlog_file(datasink, connection);
/*
MDEV-38147: Do not flush and copy the donor's current binary log here.
This used to ship the binary log to the SST joiner, but the joiner no
longer uses it - it starts a fresh binary log and seeds its GTID position
from the storage-engine checkpoint (see wsrep_seed_binlog_gtid_state() in
sql/log.cc and scripts/wsrep_sst_mariabackup.sh). Flushing here only
rotated the donor's binary log needlessly on every SST.
*/

if (result)
msg("Writing Galera info succeeded with %s:%s %s",
Expand All @@ -1522,88 +1528,6 @@ write_galera_info(ds_ctxt *datasink, MYSQL *connection)
}


/*********************************************************************//**
Flush and copy the current binary log file into the backup,
if GTID is enabled */
bool
write_current_binlog_file(ds_ctxt *datasink, MYSQL *connection)
{
char *executed_gtid_set = NULL;
char *gtid_binlog_state = NULL;
char *log_bin_file = NULL;
char *log_bin_dir = NULL;
bool gtid_exists;
bool result = true;
char filepath[FN_REFLEN];

mysql_variable status[] = {
{"Executed_Gtid_Set", &executed_gtid_set},
{NULL, NULL}
};

mysql_variable status_after_flush[] = {
{"File", &log_bin_file},
{NULL, NULL}
};

mysql_variable vars[] = {
{"gtid_binlog_state", &gtid_binlog_state},
{"log_bin_basename", &log_bin_dir},
{NULL, NULL}
};

read_mysql_variables(connection, "SHOW MASTER STATUS", status, false);
read_mysql_variables(connection, "SHOW VARIABLES", vars, true);

gtid_exists = (executed_gtid_set && *executed_gtid_set)
|| (gtid_binlog_state && *gtid_binlog_state);

if (gtid_exists) {
size_t log_bin_dir_length;

xb_mysql_query(connection, "FLUSH BINARY LOGS", false);

read_mysql_variables(connection, "SHOW MASTER STATUS",
status_after_flush, false);

if (opt_log_bin != NULL && strchr(opt_log_bin, FN_LIBCHAR)) {
/* If log_bin is set, it has priority */
if (log_bin_dir) {
free(log_bin_dir);
}
log_bin_dir = strdup(opt_log_bin);
} else if (log_bin_dir == NULL) {
/* Default location is MySQL datadir */
log_bin_dir = strdup("./");
}

dirname_part(log_bin_dir, log_bin_dir, &log_bin_dir_length);

/* strip final slash if it is not the only path component */
if (log_bin_dir_length > 1 &&
log_bin_dir[log_bin_dir_length - 1] == FN_LIBCHAR) {
log_bin_dir[log_bin_dir_length - 1] = 0;
}

if (log_bin_dir == NULL || log_bin_file == NULL) {
msg("Failed to get master binlog coordinates from "
"SHOW MASTER STATUS");
result = false;
goto cleanup;
}

snprintf(filepath, sizeof(filepath), "%s%c%s",
log_bin_dir, FN_LIBCHAR, log_bin_file);
result = datasink->copy_file(filepath, log_bin_file, 0);
}

cleanup:
free_mysql_variables(status_after_flush);
free_mysql_variables(status);
free_mysql_variables(vars);

return(result);
}


/*********************************************************************//**
Expand Down
3 changes: 0 additions & 3 deletions extra/mariabackup/backup_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ xb_mysql_query(MYSQL *connection, const char *query, bool use_result,
void
unlock_all(MYSQL *connection);

bool
write_current_binlog_file(ds_ctxt *datasink, MYSQL *connection);

bool
write_binlog_info(ds_ctxt *datasink, MYSQL *connection);

Expand Down
43 changes: 43 additions & 0 deletions mysql-test/suite/galera_3nodes/r/MDEV-38147.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_3;
connection node_1;
# gtid_strict_mode must be enabled on all nodes
SELECT @@global.gtid_strict_mode AS gtid_strict_mode;
gtid_strict_mode
1
connection node_2;
connection node_3;
connect node_1_load, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connect node_2_load, 127.0.0.1, root, , test, $NODE_MYPORT_2;
connection node_1_load;
CALL p_load();
connection node_2_load;
CALL p_load();
connection node_1;
connection node_2;
connection node_3;
connection node_1;
UPDATE ctrl SET stop = 1 WHERE id = 1;
connection node_1_load;
connection node_2_load;
connection node_1;
SET SESSION wsrep_sync_wait = 15;
SELECT VARIABLE_VALUE AS wsrep_cluster_size FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
wsrep_cluster_size
3
connection node_2;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match gtid_match
1 1 1
connection node_3;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match gtid_match
1 1 1
connection node_1;
connection node_2;
connection node_3;
disconnect node_2;
disconnect node_1;
47 changes: 47 additions & 0 deletions mysql-test/suite/galera_3nodes/r/MDEV-40179.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_3;
connection node_1;
connection node_2;
connection node_3;
connection n1_load_1;
CALL p_load('t1_1');
connection n2_load_1;
CALL p_load('t1_5');
connection n1_load_2;
CALL p_load('t1_2');
connection n2_load_2;
CALL p_load('t1_6');
connection n1_load_3;
CALL p_load('t1_3');
connection n2_load_3;
CALL p_load('t1_7');
connection n1_load_4;
CALL p_load('t1_4');
connection n2_load_4;
CALL p_load('t1_8');
connection node_1;
connection node_2;
connection node_3;
connection node_1;
UPDATE ctrl SET stop = 1 WHERE id = 1;
connection node_1;
SET SESSION wsrep_sync_wait = 15;
SELECT VARIABLE_VALUE AS wsrep_cluster_size FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
wsrep_cluster_size
3
connection node_2;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match gtid_match
1 1 1
connection node_3;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match gtid_match
1 1 1
connection node_1;
connection node_2;
connection node_3;
disconnect node_2;
disconnect node_1;
47 changes: 47 additions & 0 deletions mysql-test/suite/galera_3nodes/r/MDEV-40179_nobinlog.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_3;
connection node_1;
connection node_2;
connection node_3;
connection n1_load_1;
CALL p_load('t1_1');
connection n2_load_1;
CALL p_load('t1_5');
connection n1_load_2;
CALL p_load('t1_2');
connection n2_load_2;
CALL p_load('t1_6');
connection n1_load_3;
CALL p_load('t1_3');
connection n2_load_3;
CALL p_load('t1_7');
connection n1_load_4;
CALL p_load('t1_4');
connection n2_load_4;
CALL p_load('t1_8');
connection node_1;
connection node_2;
connection node_3;
connection node_1;
UPDATE ctrl SET stop = 1 WHERE id = 1;
connection node_1;
SET SESSION wsrep_sync_wait = 15;
SELECT VARIABLE_VALUE AS wsrep_cluster_size FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
wsrep_cluster_size
3
connection node_2;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match
1 1
connection node_3;
SET SESSION wsrep_sync_wait = 15;
count_match checksum_match
1 1
connection node_1;
connection node_2;
connection node_3;
disconnect node_2;
disconnect node_1;
25 changes: 25 additions & 0 deletions mysql-test/suite/galera_3nodes/t/MDEV-38147.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
!include ../galera_3nodes.cnf

[mysqld]
wsrep_sst_method=mariabackup
wsrep_sst_auth="root:"
gtid_strict_mode=ON
wsrep_gtid_mode=ON
wsrep_gtid_domain_id=100
gtid_domain_id=10
log_bin
log_slave_updates=ON
wsrep_slave_threads=4

[mysqld.1]
server_id=11

[mysqld.2]
server_id=12

[mysqld.3]
server_id=13

[sst]
transferfmt=@ENV.MTR_GALERA_TFMT
streamfmt=mbstream
Loading