summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/galera/include/print_gtid.inc11
-rw-r--r--mysql-test/suite/galera/r/galera_var_gtid_domain_id.result74
-rw-r--r--mysql-test/suite/galera/t/galera_var_gtid_domain_id.cnf16
-rw-r--r--mysql-test/suite/galera/t/galera_var_gtid_domain_id.test53
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_wsrep.result28
-rw-r--r--mysql-test/suite/sys_vars/r/wsrep_gtid_domain_id_basic.result47
-rw-r--r--mysql-test/suite/sys_vars/r/wsrep_gtid_mode_basic.result31
-rw-r--r--mysql-test/suite/sys_vars/t/wsrep_gtid_domain_id_basic.test43
-rw-r--r--mysql-test/suite/sys_vars/t/wsrep_gtid_mode_basic.test33
-rw-r--r--scripts/wsrep_sst_common.sh4
-rw-r--r--scripts/wsrep_sst_mysqldump.sh14
-rw-r--r--scripts/wsrep_sst_rsync.sh12
-rw-r--r--scripts/wsrep_sst_xtrabackup-v2.sh11
-rw-r--r--scripts/wsrep_sst_xtrabackup.sh9
-rw-r--r--sql/log.cc21
-rw-r--r--sql/sys_vars.cc16
-rw-r--r--sql/wsrep_mysqld.cc12
-rw-r--r--sql/wsrep_mysqld.h2
-rw-r--r--sql/wsrep_sst.cc60
-rw-r--r--sql/wsrep_sst.h1
20 files changed, 473 insertions, 25 deletions
diff --git a/mysql-test/suite/galera/include/print_gtid.inc b/mysql-test/suite/galera/include/print_gtid.inc
new file mode 100644
index 00000000000..e6bd627e5ad
--- /dev/null
+++ b/mysql-test/suite/galera/include/print_gtid.inc
@@ -0,0 +1,11 @@
+--echo list of GTID variables :
+--disable_query_log
+query_vertical
+SELECT @@global.gtid_domain_id AS gtid_domain_id,
+ @@global.gtid_binlog_pos AS gtid_binlog_pos,
+ @@global.gtid_binlog_state AS gtid_binlog_state,
+ @@global.gtid_current_pos AS gtid_current_pos,
+ @@global.gtid_slave_pos AS gtid_slave_pos,
+ @@global.wsrep_gtid_domain_id AS wsrep_gtid_domain_id,
+ @@global.wsrep_gtid_mode AS wsrep_gtid_mode;
+--enable_query_log
diff --git a/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result b/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result
new file mode 100644
index 00000000000..8e84236d5bf
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_var_gtid_domain_id.result
@@ -0,0 +1,74 @@
+# On node_1
+list of GTID variables :
+gtid_domain_id 1
+gtid_binlog_pos
+gtid_binlog_state
+gtid_current_pos
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_2
+list of GTID variables :
+gtid_domain_id 2
+gtid_binlog_pos
+gtid_binlog_state
+gtid_current_pos
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_1
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+CREATE TABLE t2(i INT) ENGINE=MEMORY;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+i
+1
+SELECT * FROM t2;
+i
+list of GTID variables :
+gtid_domain_id 1
+gtid_binlog_pos 9999-1-3
+gtid_binlog_state 9999-1-3
+gtid_current_pos 9999-1-3
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_2
+SELECT * FROM t1;
+i
+1
+list of GTID variables :
+gtid_domain_id 2
+gtid_binlog_pos 9999-1-3
+gtid_binlog_state 9999-1-3
+gtid_current_pos
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_1
+INSERT INTO t2 VALUES(1);
+SELECT * FROM t2;
+i
+1
+list of GTID variables :
+gtid_domain_id 1
+gtid_binlog_pos 1-1-1,9999-1-3
+gtid_binlog_state 1-1-1,9999-1-3
+gtid_current_pos 1-1-1,9999-1-3
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_2
+SELECT * FROM t2;
+i
+list of GTID variables :
+gtid_domain_id 2
+gtid_binlog_pos 9999-1-3
+gtid_binlog_state 9999-1-3
+gtid_current_pos
+gtid_slave_pos
+wsrep_gtid_domain_id 9999
+wsrep_gtid_mode 1
+# On node_1
+DROP TABLE t1, t2;
+# End of test
diff --git a/mysql-test/suite/galera/t/galera_var_gtid_domain_id.cnf b/mysql-test/suite/galera/t/galera_var_gtid_domain_id.cnf
new file mode 100644
index 00000000000..d3c49470f41
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_gtid_domain_id.cnf
@@ -0,0 +1,16 @@
+!include ../galera_2nodes.cnf
+
+[mysqld]
+log-bin
+log-slave-updates
+
+[mysqld.1]
+gtid_domain_id=1
+wsrep_gtid_mode=ON
+wsrep_gtid_domain_id=9999
+
+[mysqld.2]
+gtid_domain_id=2
+wsrep_gtid_mode=ON
+#wsrep_gitd_domain_id value will be inherited from donor node (mysqld.1)
+#wsrep_gitd_domain_id=X
diff --git a/mysql-test/suite/galera/t/galera_var_gtid_domain_id.test b/mysql-test/suite/galera/t/galera_var_gtid_domain_id.test
new file mode 100644
index 00000000000..c4127b4f655
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_gtid_domain_id.test
@@ -0,0 +1,53 @@
+# Test for @@wsrep_gtid_mode and @@wsrep_gtid_domain_id variables
+#
+# When @@wsrep_gtid_mode=ON, all DDL/DML commands and transactions that
+# are meant to be replicated over Galera cluster nodes are tagged with
+# galera gtid_domain_id (@@wsrep_gtid_domain_id), while others are tagged
+# with the local domain_id (@@gtid_domain_id).
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--echo # On node_1
+--connection node_1
+# print initial GTIDs
+source include/print_gtid.inc;
+
+--echo # On node_2
+--connection node_2
+# print initial GTIDs
+source include/print_gtid.inc;
+
+--echo # On node_1
+--connection node_1
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+CREATE TABLE t2(i INT) ENGINE=MEMORY;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+SELECT * FROM t2;
+source include/print_gtid.inc;
+
+--echo # On node_2
+--connection node_2
+SELECT * FROM t1;
+source include/print_gtid.inc;
+
+--echo # On node_1
+--connection node_1
+INSERT INTO t2 VALUES(1);
+SELECT * FROM t2;
+source include/print_gtid.inc;
+
+--echo # On node_2
+--connection node_2
+SELECT * FROM t2;
+source include/print_gtid.inc;
+
+--echo # On node_1
+--connection node_1
+# Cleanup
+DROP TABLE t1, t2;
+
+--source include/galera_end.inc
+--echo # End of test
+
diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
index 56a75ed8023..9c392b17f27 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
@@ -183,6 +183,34 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST MIXED,STATEMENT,ROW,NONE
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME WSREP_GTID_DOMAIN_ID
+SESSION_VALUE NULL
+GLOBAL_VALUE 0
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE 0
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE INT UNSIGNED
+VARIABLE_COMMENT When wsrep_gtid_mode is set, this value is used as gtid_domain_id for galera transactions and also copied to the joiner nodes during state transfer. It is ignored, otherwise.
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 4294967295
+NUMERIC_BLOCK_SIZE 1
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME WSREP_GTID_MODE
+SESSION_VALUE NULL
+GLOBAL_VALUE OFF
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE OFF
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT Automatically update the (joiner) node's wsrep_gtid_domain_id value with that of donor's (received during state transfer) and use it in place of gtid_domain_id for all galera transactions. When OFF (default), wsrep_gtid_domain_id is simply ignored (backward compatibility).
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME WSREP_LOAD_DATA_SPLITTING
SESSION_VALUE NULL
GLOBAL_VALUE ON
diff --git a/mysql-test/suite/sys_vars/r/wsrep_gtid_domain_id_basic.result b/mysql-test/suite/sys_vars/r/wsrep_gtid_domain_id_basic.result
new file mode 100644
index 00000000000..7c9537d095e
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/wsrep_gtid_domain_id_basic.result
@@ -0,0 +1,47 @@
+#
+# wsrep_gtid_domain_id
+#
+# save the initial value
+SET @wsrep_gtid_domain_id_global_saved = @@global.wsrep_gtid_domain_id;
+# default
+SELECT @@global.wsrep_gtid_domain_id;
+@@global.wsrep_gtid_domain_id
+0
+
+# scope
+SELECT @@session.wsrep_gtid_domain_id;
+ERROR HY000: Variable 'wsrep_gtid_domain_id' is a GLOBAL variable
+SET @@global.wsrep_gtid_domain_id=1;
+SELECT @@global.wsrep_gtid_domain_id;
+@@global.wsrep_gtid_domain_id
+1
+
+# valid values
+SET @@global.wsrep_gtid_domain_id=10;
+SELECT @@global.wsrep_gtid_domain_id;
+@@global.wsrep_gtid_domain_id
+10
+SET @@global.wsrep_gtid_domain_id=0;
+SELECT @@global.wsrep_gtid_domain_id;
+@@global.wsrep_gtid_domain_id
+0
+SET @@global.wsrep_gtid_domain_id=default;
+SELECT @global.wsrep_gtid_domain_id;
+@global.wsrep_gtid_domain_id
+NULL
+
+# invalid values
+SET @@global.wsrep_gtid_domain_id=NULL;
+ERROR 42000: Incorrect argument type to variable 'wsrep_gtid_domain_id'
+SET @@global.wsrep_gtid_domain_id='junk';
+ERROR 42000: Incorrect argument type to variable 'wsrep_gtid_domain_id'
+SET @@global.wsrep_gtid_domain_id=-1;
+Warnings:
+Warning 1292 Truncated incorrect wsrep_gtid_domain_id value: '-1'
+SELECT @global.wsrep_gtid_domain_id;
+@global.wsrep_gtid_domain_id
+NULL
+
+# restore the initial value
+SET @@global.wsrep_gtid_domain_id = @wsrep_gtid_domain_id_global_saved;
+# End of test
diff --git a/mysql-test/suite/sys_vars/r/wsrep_gtid_mode_basic.result b/mysql-test/suite/sys_vars/r/wsrep_gtid_mode_basic.result
new file mode 100644
index 00000000000..e59d6468c21
--- /dev/null
+++ b/mysql-test/suite/sys_vars/r/wsrep_gtid_mode_basic.result
@@ -0,0 +1,31 @@
+#
+# wsrep_gtid_mode
+#
+# save the initial value
+SET @wsrep_gtid_mode_global_saved = @@global.wsrep_gtid_mode;
+# default
+SELECT @@global.wsrep_gtid_mode;
+@@global.wsrep_gtid_mode
+0
+SELECT @@session.wsrep_gtid_mode;
+ERROR HY000: Variable 'wsrep_gtid_mode' is a GLOBAL variable
+
+# scope and valid values
+SET @@global.wsrep_gtid_mode=OFF;
+SELECT @@global.wsrep_gtid_mode;
+@@global.wsrep_gtid_mode
+0
+SET @@global.wsrep_gtid_mode=ON;
+SELECT @@global.wsrep_gtid_mode;
+@@global.wsrep_gtid_mode
+1
+
+# invalid values
+SET @@global.wsrep_gtid_mode=NULL;
+ERROR 42000: Variable 'wsrep_gtid_mode' can't be set to the value of 'NULL'
+SET @@global.wsrep_gtid_mode='junk';
+ERROR 42000: Variable 'wsrep_gtid_mode' can't be set to the value of 'junk'
+
+# restore the initial value
+SET @@global.wsrep_gtid_mode = @wsrep_gtid_mode_global_saved;
+# End of test
diff --git a/mysql-test/suite/sys_vars/t/wsrep_gtid_domain_id_basic.test b/mysql-test/suite/sys_vars/t/wsrep_gtid_domain_id_basic.test
new file mode 100644
index 00000000000..5608e46e0b7
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/wsrep_gtid_domain_id_basic.test
@@ -0,0 +1,43 @@
+--source include/have_wsrep.inc
+
+--echo #
+--echo # wsrep_gtid_domain_id
+--echo #
+
+--echo # save the initial value
+SET @wsrep_gtid_domain_id_global_saved = @@global.wsrep_gtid_domain_id;
+
+--echo # default
+SELECT @@global.wsrep_gtid_domain_id;
+
+--echo
+--echo # scope
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.wsrep_gtid_domain_id;
+SET @@global.wsrep_gtid_domain_id=1;
+SELECT @@global.wsrep_gtid_domain_id;
+
+--echo
+--echo # valid values
+SET @@global.wsrep_gtid_domain_id=10;
+SELECT @@global.wsrep_gtid_domain_id;
+SET @@global.wsrep_gtid_domain_id=0;
+SELECT @@global.wsrep_gtid_domain_id;
+SET @@global.wsrep_gtid_domain_id=default;
+SELECT @global.wsrep_gtid_domain_id;
+
+--echo
+--echo # invalid values
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@global.wsrep_gtid_domain_id=NULL;
+--error ER_WRONG_TYPE_FOR_VAR
+SET @@global.wsrep_gtid_domain_id='junk';
+# expect warning : Truncated incorrect wsrep_gtid_domain_id value: '-1'
+SET @@global.wsrep_gtid_domain_id=-1;
+SELECT @global.wsrep_gtid_domain_id;
+
+--echo
+--echo # restore the initial value
+SET @@global.wsrep_gtid_domain_id = @wsrep_gtid_domain_id_global_saved;
+
+--echo # End of test
diff --git a/mysql-test/suite/sys_vars/t/wsrep_gtid_mode_basic.test b/mysql-test/suite/sys_vars/t/wsrep_gtid_mode_basic.test
new file mode 100644
index 00000000000..1a749e18eaa
--- /dev/null
+++ b/mysql-test/suite/sys_vars/t/wsrep_gtid_mode_basic.test
@@ -0,0 +1,33 @@
+--source include/have_wsrep.inc
+
+--echo #
+--echo # wsrep_gtid_mode
+--echo #
+
+--echo # save the initial value
+SET @wsrep_gtid_mode_global_saved = @@global.wsrep_gtid_mode;
+
+--echo # default
+SELECT @@global.wsrep_gtid_mode;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.wsrep_gtid_mode;
+
+--echo
+--echo # scope and valid values
+SET @@global.wsrep_gtid_mode=OFF;
+SELECT @@global.wsrep_gtid_mode;
+SET @@global.wsrep_gtid_mode=ON;
+SELECT @@global.wsrep_gtid_mode;
+
+--echo
+--echo # invalid values
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.wsrep_gtid_mode=NULL;
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@global.wsrep_gtid_mode='junk';
+
+--echo
+--echo # restore the initial value
+SET @@global.wsrep_gtid_mode = @wsrep_gtid_mode_global_saved;
+
+--echo # End of test
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh
index 574657f1a76..d30ca0773f9 100644
--- a/scripts/wsrep_sst_common.sh
+++ b/scripts/wsrep_sst_common.sh
@@ -91,6 +91,10 @@ case "$1" in
WSREP_SST_OPT_BINLOG="$2"
shift
;;
+ '--gtid-domain-id')
+ readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
+ shift
+ ;;
*) # must be command
# usage
# exit 1
diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh
index b9b63c81443..a52a9290f15 100644
--- a/scripts/wsrep_sst_mysqldump.sh
+++ b/scripts/wsrep_sst_mysqldump.sh
@@ -96,6 +96,17 @@ DROP PREPARE stmt;"
SET_START_POSITION="SET GLOBAL wsrep_start_position='$WSREP_SST_OPT_GTID';"
+SET_WSREP_GTID_DOMAIN_ID=""
+if [ -n WSREP_SST_OPT_GTID_DOMAIN_ID]
+then
+ 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 @stmt = IF (@val IS NOT NULL, 'SET GLOBAL WSREP_GTID_DOMAIN_ID=$WSREP_SST_OPT_GTID_DOMAIN_ID', 'SET @dummy = 0');
+ PREPARE stmt FROM @stmt;
+ EXECUTE stmt;
+ DROP PREPARE stmt;"
+fi
+
# Retrieve the donor's @@global.gtid_binlog_state.
GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE 'gtid_binlog_state'" |\
mysql $AUTH -S$WSREP_SST_OPT_SOCKET --disable-reconnect --connect_timeout=10 |\
@@ -157,7 +168,8 @@ then
echo $SET_GTID_BINLOG_STATE && echo $SQL_LOG_BIN_OFF && \
echo $STOP_WSREP && $MYSQLDUMP && echo $CSV_TABLES_FIX && \
echo $RESTORE_GENERAL_LOG && echo $RESTORE_SLOW_QUERY_LOG && \
- echo $SET_START_POSITION || echo "SST failed to complete;") | $MYSQL
+ echo $SET_START_POSITION && echo $SET_WSREP_GTID_DOMAIN_ID \
+ || echo "SST failed to complete;") | $MYSQL
else
wsrep_log_info "Bypassing state dump."
echo $SET_START_POSITION | $MYSQL
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index 0351d3fbafb..576ce212261 100644
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -131,7 +131,9 @@ then
echo "flush tables"
- # wait for tables flushed and state ID written to the file
+ # Wait for :
+ # (a) tables to be flushed, and
+ # (b) state ID & wsrep_gtid_domain_id to be written to the file.
while [ ! -r "$FLUSHED" ] && ! grep -q ':' "$FLUSHED" >/dev/null 2>&1
do
sleep 0.2
@@ -217,7 +219,10 @@ then
else # BYPASS
wsrep_log_info "Bypassing state dump."
- STATE="$WSREP_SST_OPT_GTID"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ STATE="$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID"
fi
echo "continue" # now server can resume updating data
@@ -323,7 +328,8 @@ EOF
fi
if [ -r "$MAGIC_FILE" ]
then
- cat "$MAGIC_FILE" # output UUID:seqno
+ # UUID:seqno & wsrep_gtid_domain_id is received here.
+ cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id
else
# this message should cause joiner to abort
echo "rsync process ended without creating '$MAGIC_FILE'"
diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh
index fef8303f8f2..3b4efb2422f 100644
--- a/scripts/wsrep_sst_xtrabackup-v2.sh
+++ b/scripts/wsrep_sst_xtrabackup-v2.sh
@@ -604,7 +604,9 @@ then
wsrep_log_info "Streaming GTID file before SST"
- echo "${WSREP_SST_OPT_GTID}" > "${MAGIC_FILE}"
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
ttcmd="$tcmd"
@@ -660,7 +662,10 @@ then
wsrep_log_info "Bypassing the SST for IST"
echo "continue" # now server can resume updating data
- echo "${WSREP_SST_OPT_GTID}" > "${MAGIC_FILE}"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space).
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
echo "1" > "${DATA}/${IST_FILE}"
get_keys
if [[ $encrypt -eq 1 ]];then
@@ -923,7 +928,7 @@ then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2
fi
- cat "${MAGIC_FILE}" # output UUID:seqno
+ cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
wsrep_log_info "Total time on joiner: $totime seconds"
fi
diff --git a/scripts/wsrep_sst_xtrabackup.sh b/scripts/wsrep_sst_xtrabackup.sh
index d3681a21208..131eda765de 100644
--- a/scripts/wsrep_sst_xtrabackup.sh
+++ b/scripts/wsrep_sst_xtrabackup.sh
@@ -487,13 +487,14 @@ then
# innobackupex implicitly writes PID to fixed location in ${TMPDIR}
XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid"
-
else # BYPASS FOR IST
wsrep_log_info "Bypassing the SST for IST"
- STATE="${WSREP_SST_OPT_GTID}"
echo "continue" # now server can resume updating data
- echo "${STATE}" > "${MAGIC_FILE}"
+
+ # Store donor's wsrep GTID (state ID) and wsrep_gtid_domain_id
+ # (separated by a space)
+ echo "${WSREP_SST_OPT_GTID} ${WSREP_SST_OPT_GTID_DOMAIN_ID}" > "${MAGIC_FILE}"
echo "1" > "${DATA}/${IST_FILE}"
get_keys
pushd ${DATA} 1>/dev/null
@@ -708,7 +709,7 @@ then
exit 2
fi
- cat "${MAGIC_FILE}" # output UUID:seqno
+ cat "${MAGIC_FILE}" # Output : UUID:seqno wsrep_gtid_domain_id
wsrep_log_info "Total time on joiner: $totime seconds"
fi
diff --git a/sql/log.cc b/sql/log.cc
index 0eb475433bd..f94fe12a6f3 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -5616,13 +5616,26 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
bool is_transactional, uint64 commit_id)
{
rpl_gtid gtid;
- uint32 domain_id= thd->variables.gtid_domain_id;
- uint32 server_id= thd->variables.server_id;
- uint64 seq_no= thd->variables.gtid_seq_no;
+ uint32 domain_id;
+ uint32 server_id;
+ uint64 seq_no;
int err;
DBUG_ENTER("write_gtid_event");
DBUG_PRINT("enter", ("standalone: %d", standalone));
-
+
+#ifdef WITH_WSREP
+ if (WSREP(thd) && thd->wsrep_trx_meta.gtid.seqno != -1 && wsrep_gtid_mode)
+ {
+ domain_id= wsrep_gtid_domain_id;
+ } else {
+#endif /* WITH_WSREP */
+ domain_id= thd->variables.gtid_domain_id;
+#ifdef WITH_WSREP
+ }
+#endif /* WITH_WSREP */
+ server_id= thd->variables.server_id;
+ seq_no= thd->variables.gtid_seq_no;
+
if (thd->variables.option_bits & OPTION_GTID_BEGIN)
{
DBUG_PRINT("error", ("OPTION_GTID_BEGIN is set. "
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 0dea5a134e9..8371df0f0a6 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4859,6 +4859,22 @@ static Sys_var_mybool Sys_wsrep_dirty_reads(
"is not ready.", SESSION_ONLY(wsrep_dirty_reads), NO_CMD_LINE,
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG);
+static Sys_var_uint Sys_wsrep_gtid_domain_id(
+ "wsrep_gtid_domain_id", "When wsrep_gtid_mode is set, this value is "
+ "used as gtid_domain_id for galera transactions and also copied to the "
+ "joiner nodes during state transfer. It is ignored, otherwise.",
+ GLOBAL_VAR(wsrep_gtid_domain_id), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1), NO_MUTEX_GUARD,
+ NOT_IN_BINLOG);
+
+static Sys_var_mybool Sys_wsrep_gtid_mode(
+ "wsrep_gtid_mode", "Automatically update the (joiner) node's "
+ "wsrep_gtid_domain_id value with that of donor's (received during "
+ "state transfer) and use it in place of gtid_domain_id for all galera "
+ "transactions. When OFF (default), wsrep_gtid_domain_id is simply "
+ "ignored (backward compatibility).",
+ GLOBAL_VAR(wsrep_gtid_mode), CMD_LINE(OPT_ARG), DEFAULT(FALSE));
+
#endif /* WITH_WSREP */
static bool fix_host_cache_size(sys_var *, THD *, enum_var_type)
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 19736cef7bf..a441f86df40 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -89,6 +89,12 @@ my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave
my_bool wsrep_slave_UK_checks = 0; // slave thread does UK checks
my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks
bool wsrep_new_cluster = false; // Bootstrap the cluster ?
+
+// Use wsrep_gtid_domain_id for galera transactions?
+bool wsrep_gtid_mode = 0;
+// gtid_domain_id for galera transactions.
+uint32 wsrep_gtid_domain_id = 0;
+
/*
* End configuration options
*/
@@ -1711,6 +1717,12 @@ pthread_handler_t start_wsrep_THD(void *arg)
mysql_mutex_lock(&LOCK_thread_count);
thd->thread_id=thread_id++;
+ if (wsrep_gtid_mode)
+ {
+ /* Adjust domain_id. */
+ thd->variables.gtid_domain_id= wsrep_gtid_domain_id;
+ }
+
thd->real_id=pthread_self(); // Keep purify happy
thread_count++;
thread_created++;
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 085dc5de453..ce40cec5835 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -88,6 +88,8 @@ extern my_bool wsrep_slave_FK_checks;
extern my_bool wsrep_slave_UK_checks;
extern ulong wsrep_running_threads;
extern bool wsrep_new_cluster;
+extern bool wsrep_gtid_mode;
+extern uint32 wsrep_gtid_domain_id;
enum enum_wsrep_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
enum enum_wsrep_sync_wait {
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index d170ff91bbc..512e8f23dd8 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -435,17 +435,53 @@ static void* sst_joiner_thread (void* a)
if (!tmp)
{
- WSREP_ERROR("Failed to read uuid:seqno from joiner script.");
+ WSREP_ERROR("Failed to read uuid:seqno and wsrep_gtid_domain_id from "
+ "joiner script.");
if (proc.error()) err = proc.error();
}
else
{
- err= sst_scan_uuid_seqno (out, &ret_uuid, &ret_seqno);
+ // Read state ID (UUID:SEQNO) followed by wsrep_gtid_domain_id (if any).
+ const char *pos= strchr(out, ' ');
+
+ if (!pos) {
+ // There is no wsrep_gtid_domain_id (some older version SST script?).
+ err= sst_scan_uuid_seqno (out, &ret_uuid, &ret_seqno);
+
+ } else {
+ // Scan state ID first followed by wsrep_gtid_domain_id.
+ char uuid[512];
+ uint32 domain_id;
+ size_t len= pos - out + 1;
+
+ if (len > sizeof(uuid)) goto err; // safety check
+ memcpy(uuid, out, len); // including '\0'
+ err= sst_scan_uuid_seqno (uuid, &ret_uuid, &ret_seqno);
+
+ if (err)
+ {
+ goto err;
+ }
+ else if (wsrep_gtid_mode)
+ {
+ domain_id= strtol(pos + 1, NULL, 10);
+ if (domain_id < 1000 || domain_id > 0xFFFF)
+ {
+ WSREP_ERROR("Failed to get donor wsrep_gtid_domain_id.");
+ err= EINVAL;
+ goto err;
+ } else {
+ wsrep_gtid_domain_id= domain_id;
+ }
+ }
+ }
}
+err:
+
if (err)
{
- ret_uuid= WSREP_UUID_UNDEFINED;
+ ret_uuid= WSREP_UUID_UNDEFINED;
ret_seqno= -err;
}
@@ -784,11 +820,12 @@ static int sst_donate_mysqldump (const char* addr,
WSREP_SST_OPT_LPORT" '%u' "
WSREP_SST_OPT_SOCKET" '%s' "
" %s "
- WSREP_SST_OPT_GTID" '%s:%lld'"
+ WSREP_SST_OPT_GTID" '%s:%lld' "
+ WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
"%s",
user, pswd, host, port, mysqld_port, mysqld_unix_port,
- wsrep_defaults_file, uuid_str,
- (long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : "");
+ wsrep_defaults_file, uuid_str, (long long)seqno,
+ wsrep_gtid_domain_id, bypass ? " "WSREP_SST_OPT_BYPASS : "");
WSREP_DEBUG("Running: '%s'", cmd_str);
@@ -885,8 +922,10 @@ static int sst_flush_tables(THD* thd)
}
else
{
- fprintf(file, "%s:%lld\n",
- wsrep_cluster_state_uuid, (long long)wsrep_locked_seqno);
+ // Write cluster state ID and wsrep_gtid_domain_id.
+ fprintf(file, "%s:%lld %d\n",
+ wsrep_cluster_state_uuid, (long long)wsrep_locked_seqno,
+ wsrep_gtid_domain_id);
fsync(fileno(file));
fclose(file);
if (rename(tmp_name, real_name) == -1)
@@ -1058,12 +1097,13 @@ static int sst_donate_other (const char* method,
WSREP_SST_OPT_DATA" '%s' "
" %s "
" %s '%s' "
- WSREP_SST_OPT_GTID" '%s:%lld'"
+ WSREP_SST_OPT_GTID" '%s:%lld' "
+ WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
"%s",
method, addr, sst_auth_real, mysqld_unix_port,
mysql_real_data_home, wsrep_defaults_file,
binlog_opt, binlog_opt_val,
- uuid, (long long) seqno,
+ uuid, (long long) seqno, wsrep_gtid_domain_id,
bypass ? " "WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val);
diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h
index 2a6ab406297..49dd5b39fad 100644
--- a/sql/wsrep_sst.h
+++ b/sql/wsrep_sst.h
@@ -42,6 +42,7 @@
#define WSREP_SST_OPT_SOCKET "--socket"
#define WSREP_SST_OPT_GTID "--gtid"
#define WSREP_SST_OPT_BYPASS "--bypass"
+#define WSREP_SST_OPT_GTID_DOMAIN_ID "--gtid-domain-id"
#define WSREP_SST_MYSQLDUMP "mysqldump"
#define WSREP_SST_RSYNC "rsync"