Commit 34d86ac9 authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-6594: Use separate domain_id for Galera transactions

parent 0f8cb3c3
--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
# 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
!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
# 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
...@@ -183,6 +183,34 @@ NUMERIC_BLOCK_SIZE NULL ...@@ -183,6 +183,34 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST MIXED,STATEMENT,ROW,NONE ENUM_VALUE_LIST MIXED,STATEMENT,ROW,NONE
READ_ONLY NO READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED 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 VARIABLE_NAME WSREP_LOAD_DATA_SPLITTING
SESSION_VALUE NULL SESSION_VALUE NULL
GLOBAL_VALUE ON GLOBAL_VALUE ON
......
#
# 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
#
# 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
--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
--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
...@@ -91,6 +91,10 @@ case "$1" in ...@@ -91,6 +91,10 @@ case "$1" in
WSREP_SST_OPT_BINLOG="$2" WSREP_SST_OPT_BINLOG="$2"
shift shift
;; ;;
'--gtid-domain-id')
readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2"
shift
;;
*) # must be command *) # must be command
# usage # usage
# exit 1 # exit 1
......
...@@ -96,6 +96,17 @@ DROP PREPARE stmt;" ...@@ -96,6 +96,17 @@ 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=""
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. # Retrieve the donor's @@global.gtid_binlog_state.
GTID_BINLOG_STATE=$(echo "SHOW GLOBAL VARIABLES LIKE '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 |\ mysql $AUTH -S$WSREP_SST_OPT_SOCKET --disable-reconnect --connect_timeout=10 |\
...@@ -157,7 +168,8 @@ then ...@@ -157,7 +168,8 @@ then
echo $SET_GTID_BINLOG_STATE && echo $SQL_LOG_BIN_OFF && \ echo $SET_GTID_BINLOG_STATE && echo $SQL_LOG_BIN_OFF && \
echo $STOP_WSREP && $MYSQLDUMP && echo $CSV_TABLES_FIX && \ echo $STOP_WSREP && $MYSQLDUMP && echo $CSV_TABLES_FIX && \
echo $RESTORE_GENERAL_LOG && echo $RESTORE_SLOW_QUERY_LOG && \ 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 else
wsrep_log_info "Bypassing state dump." wsrep_log_info "Bypassing state dump."
echo $SET_START_POSITION | $MYSQL echo $SET_START_POSITION | $MYSQL
......
...@@ -131,7 +131,9 @@ then ...@@ -131,7 +131,9 @@ then
echo "flush tables" 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 while [ ! -r "$FLUSHED" ] && ! grep -q ':' "$FLUSHED" >/dev/null 2>&1
do do
sleep 0.2 sleep 0.2
...@@ -217,7 +219,10 @@ then ...@@ -217,7 +219,10 @@ then
else # BYPASS else # BYPASS
wsrep_log_info "Bypassing state dump." 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 fi
echo "continue" # now server can resume updating data echo "continue" # now server can resume updating data
...@@ -323,7 +328,8 @@ EOF ...@@ -323,7 +328,8 @@ EOF
fi fi
if [ -r "$MAGIC_FILE" ] if [ -r "$MAGIC_FILE" ]
then 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 else
# this message should cause joiner to abort # this message should cause joiner to abort
echo "rsync process ended without creating '$MAGIC_FILE'" echo "rsync process ended without creating '$MAGIC_FILE'"
......
...@@ -604,7 +604,9 @@ then ...@@ -604,7 +604,9 @@ then
wsrep_log_info "Streaming GTID file before SST" 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" ttcmd="$tcmd"
...@@ -660,7 +662,10 @@ then ...@@ -660,7 +662,10 @@ then
wsrep_log_info "Bypassing the SST for IST" wsrep_log_info "Bypassing the SST for IST"
echo "continue" # now server can resume updating data 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}" echo "1" > "${DATA}/${IST_FILE}"
get_keys get_keys
if [[ $encrypt -eq 1 ]];then if [[ $encrypt -eq 1 ]];then
...@@ -923,7 +928,7 @@ then ...@@ -923,7 +928,7 @@ then
wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable" wsrep_log_error "SST magic file ${MAGIC_FILE} not found/readable"
exit 2 exit 2
fi 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" wsrep_log_info "Total time on joiner: $totime seconds"
fi fi
......
...@@ -487,13 +487,14 @@ then ...@@ -487,13 +487,14 @@ then
# innobackupex implicitly writes PID to fixed location in ${TMPDIR} # innobackupex implicitly writes PID to fixed location in ${TMPDIR}
XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid" XTRABACKUP_PID="${TMPDIR}/xtrabackup_pid"
else # BYPASS FOR IST else # BYPASS FOR IST
wsrep_log_info "Bypassing the SST for IST" wsrep_log_info "Bypassing the SST for IST"
STATE="${WSREP_SST_OPT_GTID}"
echo "continue" # now server can resume updating data 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}" echo "1" > "${DATA}/${IST_FILE}"
get_keys get_keys
pushd ${DATA} 1>/dev/null pushd ${DATA} 1>/dev/null
...@@ -708,7 +709,7 @@ then ...@@ -708,7 +709,7 @@ then
exit 2 exit 2
fi 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" wsrep_log_info "Total time on joiner: $totime seconds"
fi fi
......
...@@ -5616,13 +5616,26 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, ...@@ -5616,13 +5616,26 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
bool is_transactional, uint64 commit_id) bool is_transactional, uint64 commit_id)
{ {
rpl_gtid gtid; rpl_gtid gtid;
uint32 domain_id= thd->variables.gtid_domain_id; uint32 domain_id;
uint32 server_id= thd->variables.server_id; uint32 server_id;
uint64 seq_no= thd->variables.gtid_seq_no; uint64 seq_no;
int err; int err;
DBUG_ENTER("write_gtid_event"); DBUG_ENTER("write_gtid_event");
DBUG_PRINT("enter", ("standalone: %d", standalone)); 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) if (thd->variables.option_bits & OPTION_GTID_BEGIN)
{ {
DBUG_PRINT("error", ("OPTION_GTID_BEGIN is set. " DBUG_PRINT("error", ("OPTION_GTID_BEGIN is set. "
......
...@@ -4859,6 +4859,22 @@ static Sys_var_mybool Sys_wsrep_dirty_reads( ...@@ -4859,6 +4859,22 @@ static Sys_var_mybool Sys_wsrep_dirty_reads(
"is not ready.", SESSION_ONLY(wsrep_dirty_reads), NO_CMD_LINE, "is not ready.", SESSION_ONLY(wsrep_dirty_reads), NO_CMD_LINE,
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG); 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 */ #endif /* WITH_WSREP */
static bool fix_host_cache_size(sys_var *, THD *, enum_var_type) static bool fix_host_cache_size(sys_var *, THD *, enum_var_type)
......
...@@ -89,6 +89,12 @@ my_bool wsrep_restart_slave_activated = 0; // node has dropped, and slave ...@@ -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_UK_checks = 0; // slave thread does UK checks
my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks my_bool wsrep_slave_FK_checks = 0; // slave thread does FK checks
bool wsrep_new_cluster = false; // Bootstrap the cluster ? 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 * End configuration options
*/ */
...@@ -1711,6 +1717,12 @@ pthread_handler_t start_wsrep_THD(void *arg) ...@@ -1711,6 +1717,12 @@ pthread_handler_t start_wsrep_THD(void *arg)
mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_lock(&LOCK_thread_count);
thd->thread_id=thread_id++; 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 thd->real_id=pthread_self(); // Keep purify happy
thread_count++; thread_count++;
thread_created++; thread_created++;
......
...@@ -88,6 +88,8 @@ extern my_bool wsrep_slave_FK_checks; ...@@ -88,6 +88,8 @@ extern my_bool wsrep_slave_FK_checks;
extern my_bool wsrep_slave_UK_checks; extern my_bool wsrep_slave_UK_checks;
extern ulong wsrep_running_threads; extern ulong wsrep_running_threads;
extern bool wsrep_new_cluster; 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_OSU_method { WSREP_OSU_TOI, WSREP_OSU_RSU };
enum enum_wsrep_sync_wait { enum enum_wsrep_sync_wait {
......
...@@ -435,17 +435,53 @@ static void* sst_joiner_thread (void* a) ...@@ -435,17 +435,53 @@ static void* sst_joiner_thread (void* a)
if (!tmp) 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(); if (proc.error()) err = proc.error();
} }
else 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) if (err)
{ {
ret_uuid= WSREP_UUID_UNDEFINED; ret_uuid= WSREP_UUID_UNDEFINED;
ret_seqno= -err; ret_seqno= -err;
} }
...@@ -784,11 +820,12 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -784,11 +820,12 @@ static int sst_donate_mysqldump (const char* addr,
WSREP_SST_OPT_LPORT" '%u' " WSREP_SST_OPT_LPORT" '%u' "
WSREP_SST_OPT_SOCKET" '%s' " WSREP_SST_OPT_SOCKET" '%s' "
" %s " " %s "
WSREP_SST_OPT_GTID" '%s:%lld'" WSREP_SST_OPT_GTID" '%s:%lld' "
WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
"%s", "%s",
user, pswd, host, port, mysqld_port, mysqld_unix_port, user, pswd, host, port, mysqld_port, mysqld_unix_port,
wsrep_defaults_file, uuid_str, wsrep_defaults_file, uuid_str, (long long)seqno,
(long long)seqno, bypass ? " "WSREP_SST_OPT_BYPASS : ""); wsrep_gtid_domain_id, bypass ? " "WSREP_SST_OPT_BYPASS : "");
WSREP_DEBUG("Running: '%s'", cmd_str); WSREP_DEBUG("Running: '%s'", cmd_str);
...@@ -885,8 +922,10 @@ static int sst_flush_tables(THD* thd) ...@@ -885,8 +922,10 @@ static int sst_flush_tables(THD* thd)
} }
else else
{ {
fprintf(file, "%s:%lld\n", // Write cluster state ID and wsrep_gtid_domain_id.
wsrep_cluster_state_uuid, (long long)wsrep_locked_seqno); fprintf(file, "%s:%lld %d\n",
wsrep_cluster_state_uuid, (long long)wsrep_locked_seqno,
wsrep_gtid_domain_id);
fsync(fileno(file)); fsync(fileno(file));
fclose(file); fclose(file);
if (rename(tmp_name, real_name) == -1) if (rename(tmp_name, real_name) == -1)
...@@ -1058,12 +1097,13 @@ static int sst_donate_other (const char* method, ...@@ -1058,12 +1097,13 @@ static int sst_donate_other (const char* method,
WSREP_SST_OPT_DATA" '%s' " WSREP_SST_OPT_DATA" '%s' "
" %s " " %s "
" %s '%s' " " %s '%s' "
WSREP_SST_OPT_GTID" '%s:%lld'" WSREP_SST_OPT_GTID" '%s:%lld' "
WSREP_SST_OPT_GTID_DOMAIN_ID" '%d'"
"%s", "%s",
method, addr, sst_auth_real, mysqld_unix_port, method, addr, sst_auth_real, mysqld_unix_port,
mysql_real_data_home, wsrep_defaults_file, mysql_real_data_home, wsrep_defaults_file,
binlog_opt, binlog_opt_val, binlog_opt, binlog_opt_val,
uuid, (long long) seqno, uuid, (long long) seqno, wsrep_gtid_domain_id,
bypass ? " "WSREP_SST_OPT_BYPASS : ""); bypass ? " "WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val); my_free(binlog_opt_val);
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#define WSREP_SST_OPT_SOCKET "--socket" #define WSREP_SST_OPT_SOCKET "--socket"
#define WSREP_SST_OPT_GTID "--gtid" #define WSREP_SST_OPT_GTID "--gtid"
#define WSREP_SST_OPT_BYPASS "--bypass" #define WSREP_SST_OPT_BYPASS "--bypass"
#define WSREP_SST_OPT_GTID_DOMAIN_ID "--gtid-domain-id"
#define WSREP_SST_MYSQLDUMP "mysqldump" #define WSREP_SST_MYSQLDUMP "mysqldump"
#define WSREP_SST_RSYNC "rsync" #define WSREP_SST_RSYNC "rsync"
......
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