Skip to content

Commit 21b84b6

Browse files
author
Sven Sandberg
committed
BUG#20471216: 5.6 WITH GTID_MODE=X CANT CONNECT TO 5.7.6 WITH GTID_MODE=X_PERMISSIVE
This is the 5.7 version of this patch. Tests needed to be rewritten and source code is a little bit different, so null-merged from 5.6 and created a new changeset (this one) for 5.7. Background: In 5.6, GTID_MODE can only take two values: ON and OFF. In 5.7, GTID_MODE can take four values: ON, ON_PERMISSIVE, OFF_PERMISSIVE, and OFF. A 5.7 master should be able to replicate to a 5.6 slave if master uses X_PERMISSIVE and slave uses X. Problem: Due to a sanity check on the slave where the slave explicitly checks the master's GTID_MODE, the slave refuses to start replication. The 5.6 server was actually prepared to handle the new modes introduced by 5.7, but in the end the names of the modes were changed: 5.6 allows a master to have modes UPGRADE_STEP_1 and UPGRADE_STEP_2 but not ON_PERMISSIVE or OFF_PERMISSIVE. Fix: - Allow slave to replicate if the master's GTID_MODE *begins* with ON or OFF. The slave in this case will ignore the remainder of the GTID_MODE string and treat master as being ON or OFF. - Report a warning if the master's GTID_MODE begins with ON or OFF but is not equal to ON or OFF. @sql/rpl_slave.cc - Allow master's GTID_MODE to be any string that begins with ON or OFF. - Report a warning if the master's GTID_MODE begins with ON or OFF but is not equal to ON or OFF. @mysql-test/include/assert_grep.inc - Improve debug info. @mysql-test/suite/rpl/t/rpl_gtid_mode.test - In 5.7, this is a more appropriate place for the test. Also, the test is rewritten to avoid server restarts since restarts are not needed in 5.7. Also removed the .opt file for the test.
1 parent 548e95a commit 21b84b6

File tree

6 files changed

+168
-19
lines changed

6 files changed

+168
-19
lines changed

mysql-test/include/assert_grep.inc

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if (!$assert_text)
4848
}
4949
if (!$assert_file)
5050
{
51-
--die !!!ERROR IN TEST: you must set $file
51+
--die !!!ERROR IN TEST: you must set $assert_file
5252
}
5353
if (!$assert_select)
5454
{
@@ -132,8 +132,12 @@ if ($_ag_outcome != 'assert_grep.inc ok')
132132
{
133133
--source include/show_rpl_debug_info.inc
134134
--echo include/assert_grep.inc failed!
135+
--echo assert_text: '$assert_text'
136+
--echo assert_file: '$assert_file'
135137
--echo assert_select: '$assert_select'
136138
--echo assert_match: '$assert_match'
139+
--echo assert_count: '$assert_count'
140+
--echo assert_only_after: '$assert_only_after'
137141
if ($assert_match != '')
138142
{
139143
--echo matching lines: '$_ag_outcome'

mysql-test/suite/rpl/r/rpl_gtid_mode.result

+31-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ Note #### Storing MySQL user name or password information in the master info rep
66
==== Initialize ====
77
call mtr.add_suppression("Slave I/O for channel '': The replication receiver thread cannot start");
88
call mtr.add_suppression("Slave I/O for channel '': The slave IO thread stops");
9+
call mtr.add_suppression("Slave I/O for channel '': Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF");
10+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF");
11+
call mtr.add_suppression("GTID_LOG_EVENT or ANONYMOUS_GTID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT or an ANONYMOUS_GTID_LOG_EVENT.");
12+
call mtr.add_suppression("An unexpected event sequence was detected by the IO thread while queuing the event received from master");
13+
call mtr.add_suppression("Detected misconfiguration: replication channel '' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off.");
14+
call mtr.add_suppression("Slave I/O for channel '': Relay log write failure: could not queue event from master");
15+
call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON");
16+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON");
17+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate anonymous transaction when AUTO_POSITION = 1");
18+
call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate anonymous transaction when AUTO_POSITION = 1,");
19+
call mtr.add_suppression("Slave I/O for channel '': The master uses an unknown GTID_MODE 'on_something'. Treating it as 'ON'.");
20+
call mtr.add_suppression("Slave I/O for channel '': The master uses an unknown GTID_MODE 'off_something'. Treating it as 'OFF'.");
21+
call mtr.add_suppression("Could not open .* for logging.*. Turning logging off for the whole duration of the MySQL server process.");
922
include/sync_slave_sql_with_master.inc
1023
include/stop_slave.inc
1124
==== Checks performed at server start ====
@@ -160,6 +173,7 @@ include/rpl_set_gtid_mode.inc [OFF on servers 1,2]
160173
START SLAVE IO_THREAD;
161174
include/wait_for_slave_io_error.inc [errno=1236 # ER_CANT_REPLICATE_GTID_WITH_GTID_MODE_OFF]
162175
include/assert.inc [sender thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF.]
176+
include/assert_grep.inc [Receiver thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF.]
163177
[connection master]
164178
DROP TABLE t1;
165179
RESET MASTER;
@@ -213,6 +227,7 @@ include/rpl_set_gtid_mode.inc [ON on servers 1,2]
213227
START SLAVE IO_THREAD;
214228
include/wait_for_slave_io_error.inc [errno=1236 # ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON]
215229
include/assert.inc [sender thread should report - Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON.]
230+
include/assert_grep.inc [While gtid-mode=on, slave expects an anonymous event to get ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON.]
216231
[connection master]
217232
DROP TABLE t3;
218233
include/rpl_reset.inc
@@ -261,6 +276,7 @@ CHANGE MASTER TO MASTER_AUTO_POSITION= 1;
261276
START SLAVE IO_THREAD;
262277
include/wait_for_slave_io_error.inc [errno=1236 # ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION]
263278
include/assert.inc [sender thread should report - Cannot replicate anonymous transaction when AUTO_POSITION = 1.]
279+
include/assert_grep.inc [While AUTO_POSITION is enabled, Master sends an anonymous transaction resulting into ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION.]
264280
include/rpl_restart_server.inc [server_number=1 gtids=off]
265281
[connection master]
266282
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON;
@@ -353,20 +369,33 @@ include/rpl_set_gtid_mode.inc [OFF on servers 1]
353369
include/stop_slave.inc
354370
Warnings:
355371
Note 3084 Replication thread(s) for channel '' are already stopped.
372+
RESET SLAVE;
356373
SET @@GLOBAL.DEBUG= 'd,simulate_master_has_unknown_gtid_mode';
357374
START SLAVE IO_THREAD;
358375
include/wait_for_slave_io_error.inc [errno=1593]
359376
Warnings:
360377
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
361-
Last_IO_Error = 'The slave IO thread stops because the master has an unknown @@GLOBAL.GTID_MODE.'
378+
Last_IO_Error = 'The slave IO thread stops because the master has an unknown @@GLOBAL.GTID_MODE 'Krakel Spektakel'.'
362379
Warnings:
363380
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
364381
SET @@GLOBAL.DEBUG= @debug_saved;
382+
#
383+
# Warning generated if master has unknown gtid_mode that begins
384+
# with ON or OFF.
385+
#
386+
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
387+
SET @@GLOBAL.DEBUG = 'd,simulate_master_has_gtid_mode_on_something';
388+
include/start_slave.inc
389+
include/assert_grep.inc [Receiver thread should report that on_something is unknown]
390+
include/stop_slave.inc
391+
SET @@GLOBAL.DEBUG = 'd,simulate_master_has_gtid_mode_off_something';
392+
include/start_slave.inc
393+
include/assert_grep.inc [Receiver thread should report that off_something is unknown]
394+
include/stop_slave.inc
365395
RESET SLAVE;
366396
#
367397
# ER_CANT_SET_GTID_MODE generated because AUTO_POSITION = 1.
368398
#
369-
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
370399
include/rpl_set_gtid_mode.inc [ON on servers 1]
371400
CHANGE MASTER TO MASTER_AUTO_POSITION = 1;
372401
SET @@GLOBAL.GTID_MODE = OFF;

mysql-test/suite/rpl/t/rpl_gtid_mode-slave.opt

-1
This file was deleted.

mysql-test/suite/rpl/t/rpl_gtid_mode.test

+73-13
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@
4848

4949
call mtr.add_suppression("Slave I/O for channel '': The replication receiver thread cannot start");
5050
call mtr.add_suppression("Slave I/O for channel '': The slave IO thread stops");
51+
call mtr.add_suppression("Slave I/O for channel '': Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF");
52+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF");
53+
call mtr.add_suppression("GTID_LOG_EVENT or ANONYMOUS_GTID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT or an ANONYMOUS_GTID_LOG_EVENT.");
54+
call mtr.add_suppression("An unexpected event sequence was detected by the IO thread while queuing the event received from master");
55+
call mtr.add_suppression("Detected misconfiguration: replication channel '' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off.");
56+
call mtr.add_suppression("Slave I/O for channel '': Relay log write failure: could not queue event from master");
57+
call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON");
58+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON");
59+
call mtr.add_suppression("Slave I/O for channel '': Cannot replicate anonymous transaction when AUTO_POSITION = 1");
60+
call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate anonymous transaction when AUTO_POSITION = 1,");
61+
call mtr.add_suppression("Slave I/O for channel '': The master uses an unknown GTID_MODE 'on_something'. Treating it as 'ON'.");
62+
call mtr.add_suppression("Slave I/O for channel '': The master uses an unknown GTID_MODE 'off_something'. Treating it as 'OFF'.");
63+
call mtr.add_suppression("Could not open .* for logging.*. Turning logging off for the whole duration of the MySQL server process.");
64+
5165
--let $saved_binlog_error_action=`SELECT @@GLOBAL.binlog_error_action`
5266

5367
--source include/sync_slave_sql_with_master.inc
@@ -57,9 +71,9 @@ call mtr.add_suppression("Slave I/O for channel '': The slave IO thread stops");
5771
--connection master
5872
--let $saved_innodb_page_size_server1=`SELECT @@innodb_page_size`
5973

60-
--let $server1_cmd= $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-output=file --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server1
74+
--let $server1_cmd= $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server1
6175

62-
--let $server2_cmd= $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-output=file --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server2
76+
--let $server2_cmd= $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server2
6377

6478
--echo ==== Checks performed at server start ====
6579

@@ -225,6 +239,13 @@ START SLAVE IO_THREAD;
225239
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF%";
226240
--source include/assert.inc
227241

242+
--let $assert_text= Receiver thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF.
243+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
244+
--let $assert_select= Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF
245+
--let $assert_only_after= Slave I/O thread for channel '': connected to master
246+
--let $assert_count= 2
247+
--source include/assert_grep.inc
248+
228249
--source include/rpl_connection_master.inc
229250
DROP TABLE t1;
230251

@@ -262,9 +283,10 @@ CREATE TABLE t2(a int);
262283
--source include/wait_for_slave_io_error.inc
263284

264285
--let $assert_text= Receiver thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF.
265-
--let $assert_file= $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
286+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
266287
--let $assert_select= Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF
267-
--let $assert_count= 3
288+
--let $assert_only_after= Slave I/O thread for channel '': connected to master
289+
--let $assert_count= 1
268290
--source include/assert_grep.inc
269291

270292
--source include/rpl_connection_master.inc
@@ -298,7 +320,7 @@ CHANGE MASTER TO MASTER_AUTO_POSITION= 1;
298320
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON;
299321

300322
--let $assert_text= While AUTO_POSITION is set, attempt to restart the slave with gtid-mode= off to get ER_STARTING_WITH_GTID_MODE_OFF_AND_AUTO_POSITION.
301-
--let $assert_file= $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
323+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
302324
--let $assert_select= Detected misconfiguration: replication channel '' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off
303325
--let $assert_count= 1
304326
--source include/assert_grep.inc
@@ -345,6 +367,13 @@ START SLAVE IO_THREAD;
345367
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON%";
346368
--source include/assert.inc
347369

370+
--let $assert_text= While gtid-mode=on, slave expects an anonymous event to get ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON.
371+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
372+
--let $assert_select= Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON
373+
--let $assert_only_after= Slave I/O thread for channel '': connected to master
374+
--let $assert_count= 2
375+
--source include/assert_grep.inc
376+
348377
--source include/rpl_connection_master.inc
349378
DROP TABLE t3;
350379

@@ -367,9 +396,10 @@ CREATE TABLE t4(a int);
367396
--source include/wait_for_slave_io_error.inc
368397

369398
--let $assert_text= While gtid-mode=on, slave expects an anonymous event to get ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON.
370-
--let $assert_file= $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
399+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
371400
--let $assert_select= Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON
372-
--let $assert_count= 3
401+
--let $assert_only_after= Slave I/O thread for channel '': connected to master
402+
--let $assert_count= 1
373403
--source include/assert_grep.inc
374404

375405
--source include/stop_slave_sql.inc
@@ -443,6 +473,12 @@ START SLAVE IO_THREAD;
443473
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate anonymous transaction when AUTO_POSITION = 1%";
444474
--source include/assert.inc
445475

476+
--let $assert_text= While AUTO_POSITION is enabled, Master sends an anonymous transaction resulting into ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION.
477+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
478+
--let $assert_select= Cannot replicate anonymous transaction when AUTO_POSITION = 1
479+
--let $assert_count= 1
480+
--source include/assert_grep.inc
481+
446482
--let $rpl_server_number=1
447483
--let $rpl_start_with_gtids= 0
448484
--source include/rpl_restart_server.inc
@@ -523,9 +559,9 @@ START SLAVE IO_THREAD;
523559
--source include/wait_for_slave_io_error.inc
524560

525561
--let $assert_text= While AUTO_POSITION is enabled, Master sends an anonymous transaction resulting into ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION.
526-
--let $assert_file= $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
562+
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
527563
--let $assert_select= Cannot replicate anonymous transaction when AUTO_POSITION = 1
528-
--let $assert_count= 2
564+
--let $assert_count= 1
529565
--source include/assert_grep.inc
530566

531567
--source include/rpl_connection_slave.inc
@@ -603,37 +639,61 @@ INSERT INTO t7 values (1);
603639

604640
SET GTID_NEXT='AUTOMATIC';
605641
DROP TABLE t7;
606-
RESET MASTER;
607642

643+
RESET MASTER;
608644
--let $rpl_server_numbers= 1
609645
--let $rpl_skip_sync= 1
610646
--let $rpl_gtid_mode= OFF
611647
--source include/rpl_set_gtid_mode.inc
612648

649+
613650
# Get rid of the manually generated slave error log file.
614-
--remove_file $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
651+
#--remove_file $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err
615652

616653
--echo #
617654
--echo # Error generated if master has an unknown gtid_mode
618655
--echo #
619656

620657
--connection slave
621658
--source include/stop_slave.inc
659+
RESET SLAVE;
622660
SET @@GLOBAL.DEBUG= 'd,simulate_master_has_unknown_gtid_mode';
623661
START SLAVE IO_THREAD;
624662
--let $slave_io_errno= convert_error(ER_SLAVE_FATAL_ERROR)
625663
--let $show_slave_io_error= 1
626664
--source include/wait_for_slave_io_error.inc
627665
SET @@GLOBAL.DEBUG= @debug_saved;
628666

667+
--echo #
668+
--echo # Warning generated if master has unknown gtid_mode that begins
669+
--echo # with ON or OFF.
670+
--echo #
671+
672+
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
673+
674+
SET @@GLOBAL.DEBUG = 'd,simulate_master_has_gtid_mode_on_something';
675+
--source include/start_slave.inc
676+
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
677+
--let $assert_count= 1
678+
--let $assert_only_after= Slave I/O thread for channel '': connected to master
679+
--let $assert_text= Receiver thread should report that on_something is unknown
680+
--let $assert_select= Slave I/O for channel '': The master uses an unknown GTID_MODE 'on_something'. Treating it as 'ON'.
681+
--source include/assert_grep.inc
682+
683+
--source include/stop_slave.inc
684+
SET @@GLOBAL.DEBUG = 'd,simulate_master_has_gtid_mode_off_something';
685+
--source include/start_slave.inc
686+
--let $assert_text= Receiver thread should report that off_something is unknown
687+
--let $assert_select= Slave I/O for channel '': The master uses an unknown GTID_MODE 'off_something'. Treating it as 'OFF'.
688+
--source include/assert_grep.inc
689+
690+
--source include/stop_slave.inc
629691
RESET SLAVE;
630692

631693
--echo #
632694
--echo # ER_CANT_SET_GTID_MODE generated because AUTO_POSITION = 1.
633695
--echo #
634696

635-
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
636-
637697
--let $rpl_server_numbers= 1
638698
--let $rpl_gtid_mode= ON
639699
--let $rpl_skip_sync= 1

mysql-test/suite/sys_vars/t/gtid_mode_basic.test

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ SET @@global.enforce_gtid_consistency = ON;
1515
select @@global.gtid_mode;
1616
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
1717
select @@session.gtid_mode;
18+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
19+
set gtid_mode = @start_global_value;
20+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
21+
set @@session.gtid_mode = @start_global_value;
1822
show global variables like 'gtid_mode';
1923
show session variables like 'gtid_mode';
2024
--disable_warnings

sql/rpl_slave.cc

+55-2
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,25 @@ static int get_master_uuid(MYSQL *mysql, Master_info *mi)
23212321
return ret;
23222322
}
23232323

2324+
2325+
/**
2326+
Determine, case-sensitively, if short_string is equal to
2327+
long_string, or a true prefix of long_string, or not a prefix.
2328+
2329+
@retval 0 short_string is not a prefix of long_string.
2330+
@retval 1 short_string is a true prefix of long_string (not equal).
2331+
@retval 2 short_string is equal to long_string.
2332+
*/
2333+
static int is_str_prefix_case(const char *short_string, const char *long_string)
2334+
{
2335+
int i;
2336+
for (i= 0; short_string[i]; i++)
2337+
if (my_toupper(system_charset_info, short_string[i]) !=
2338+
my_toupper(system_charset_info, long_string[i]))
2339+
return 0;
2340+
return long_string[i] ? 1 : 2;
2341+
}
2342+
23242343
/*
23252344
Note that we rely on the master's version (3.23, 4.0.14 etc) instead of
23262345
relying on the binlog's version. This is not perfect: imagine an upgrade
@@ -2896,17 +2915,51 @@ when it try to get the value of TIME_ZONE global variable from master.";
28962915
{
28972916
bool error= false;
28982917
const char *master_gtid_mode_string= master_row[0];
2918+
DBUG_EXECUTE_IF("simulate_master_has_gtid_mode_on_something",
2919+
{ master_gtid_mode_string= "on_something"; });
2920+
DBUG_EXECUTE_IF("simulate_master_has_gtid_mode_off_something",
2921+
{ master_gtid_mode_string= "off_something"; });
28992922
DBUG_EXECUTE_IF("simulate_master_has_unknown_gtid_mode",
29002923
{ master_gtid_mode_string= "Krakel Spektakel"; });
29012924
master_gtid_mode= get_gtid_mode(master_gtid_mode_string, &error);
2902-
mysql_free_result(master_res);
2925+
if (error)
2926+
{
2927+
// For potential future compatibility, allow unknown
2928+
// GTID_MODEs that begin with ON/OFF (treating them as ON/OFF
2929+
// respectively).
2930+
enum_gtid_mode mode= GTID_MODE_OFF;
2931+
for (int i= 0; i < 2; i++)
2932+
{
2933+
switch (is_str_prefix_case(get_gtid_mode_string(mode),
2934+
master_gtid_mode_string))
2935+
{
2936+
case 0: // is not a prefix; continue loop
2937+
break;
2938+
case 1: // is a true prefix, i.e. not equal
2939+
mi->report(WARNING_LEVEL, ER_UNKNOWN_ERROR,
2940+
"The master uses an unknown GTID_MODE '%s'. "
2941+
"Treating it as '%s'.",
2942+
master_gtid_mode_string,
2943+
get_gtid_mode_string(mode));
2944+
// fall through
2945+
case 2: // is equal
2946+
error= false;
2947+
master_gtid_mode= mode;
2948+
break;
2949+
}
2950+
mode= GTID_MODE_ON;
2951+
}
2952+
}
29032953
if (error)
29042954
{
29052955
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
29062956
"The slave IO thread stops because the master has "
2907-
"an unknown @@GLOBAL.GTID_MODE.");
2957+
"an unknown @@GLOBAL.GTID_MODE '%s'.",
2958+
master_gtid_mode_string);
2959+
mysql_free_result(master_res);
29082960
DBUG_RETURN(1);
29092961
}
2962+
mysql_free_result(master_res);
29102963
break;
29112964
}
29122965
}

0 commit comments

Comments
 (0)