Commit e590f891 authored by unknown's avatar unknown

MDEV-26: Global transaction ID.

Fix MDEV-4278: Slave does not check that master understands GTID.

Now the slave will abort with a suitable error if an attempt is made to connect
with GTID to a master that does not support GTID.
parent 9bb989a9
......@@ -73,5 +73,17 @@ a
3
4
5
*** MDEV-4278: Slave does not detect that master is not GTID-aware ***
include/stop_slave.inc
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,simulate_non_gtid_aware_master";
START SLAVE;
include/wait_for_slave_io_error.inc [errno=1233]
SET GLOBAL debug_dbug= @old_dbug;
INSERT INTO t1 VALUES (6);
START SLAVE;
SET sql_log_bin=0;
CALL mtr.add_suppression("The slave I/O thread stops because master does not support MariaDB global transaction id");
SET sql_log_bin=1;
DROP TABLE t1;
include/rpl_end.inc
......@@ -107,6 +107,33 @@ INSERT INTO t1 VALUES (5);
SELECT * FROM t1 ORDER BY a;
--echo *** MDEV-4278: Slave does not detect that master is not GTID-aware ***
--connection slave
--source include/stop_slave.inc
--connection master
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,simulate_non_gtid_aware_master";
--connection slave
START SLAVE;
--let $slave_io_errno= 1233
--source include/wait_for_slave_io_error.inc
--connection master
SET GLOBAL debug_dbug= @old_dbug;
INSERT INTO t1 VALUES (6);
--save_master_pos
--connection slave
START SLAVE;
--sync_with_master
SET sql_log_bin=0;
CALL mtr.add_suppression("The slave I/O thread stops because master does not support MariaDB global transaction id");
SET sql_log_bin=1;
--connection master
DROP TABLE t1;
......
......@@ -5678,6 +5678,14 @@ longlong Item_func_get_system_var::val_int()
{
THD *thd= current_thd;
DBUG_EXECUTE_IF("simulate_non_gtid_aware_master",
{
if (0 == strcmp("gtid_domain_id", var->name.str))
{
my_error(ER_VAR_CANT_BE_READ, MYF(0), var->name.str);
return 0;
}
});
if (cache_present && thd->query_id == used_query_id)
{
if (cache_present & GET_SYS_VAR_CACHE_LONG)
......
......@@ -1823,6 +1823,27 @@ after_set_capability:
rpl_gtid *binlog_gtid_list= NULL;
uint32 num_binlog_gtids= 0;
/*
Read the master @@GLOBAL.gtid_domain_id variable.
This is mostly to check that master is GTID aware, but we could later
perhaps use it to check that different multi-source masters are correctly
configured with distinct domain_id.
*/
if (mysql_real_query(mysql,
STRING_WITH_LEN("SELECT @@GLOBAL.gtid_domain_id")) ||
!(master_res= mysql_store_result(mysql)) ||
!(master_row= mysql_fetch_row(master_res)))
{
err_code= mysql_errno(mysql);
errmsg= "The slave I/O thread stops because master does not support "
"MariaDB global transaction id. A fatal error is encountered when "
"it tries to SELECT @@GLOBAL.gtid_domain_id.";
sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
goto err;
}
mysql_free_result(master_res);
master_res= NULL;
if (opt_bin_log)
{
int err= mysql_bin_log.get_most_recent_gtid_list(&binlog_gtid_list,
......
......@@ -1419,6 +1419,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
connect_gtid_state.length(0);
using_gtid_state= get_slave_connect_state(thd, &connect_gtid_state);
DBUG_EXECUTE_IF("simulate_non_gtid_aware_master", using_gtid_state= false;);
if (global_system_variables.log_warnings > 1)
sql_print_information("Start binlog_dump to slave_server(%d), pos(%s, %lu)",
......
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