Skip to content

Commit b6ee6c3

Browse files
author
Joao Gramacho
committed
BUG#23180202 REPLICATION CHANNELS ARE GETTING SAME NAME IN MSR AFTER UPGRADE
Problem: After upgrading from MySQL 5.6, a MySQL 5.7 slave is not handling replication channels correctly. Analysis: The upgrade procedure is inverting the order of two fields of the mysql.slave_master_info table (Channel_Name and Tls_version). Fix: Asserted the correct position of the Channel_Name field at mysql.slave_master_info table while upgrading. Added a verification to the master_info table repository expecting that the table primary key field (Channel_name) is at the correct column, otherwise it will fail to initialize the repository.
1 parent 4cb24c6 commit b6ee6c3

14 files changed

+666
-25
lines changed

mysql-test/include/stop_slave.inc

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ if (!$rpl_debug)
4747
--disable_query_log
4848
}
4949

50+
--let $_for_channel_clause=
5051
if ($rpl_channel_name != '')
5152
{
5253
--let $_for_channel_clause= FOR CHANNEL '$rpl_channel_name'

mysql-test/include/sync_slave_sql_with_master.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# [--let $sync_slave_connection= <connection_name>]
1313
# [--let $use_gtids= 1]
14-
# [--let $rpl_channel_name= 1]
14+
# [--let $rpl_channel_name= NAME]
1515
# [--let $slave_timeout= NUMBER]
1616
# [--let $rpl_debug= 1]
1717
# [--let $wait_for_executed_gtid_set= 1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
include/rpl_init.inc [topology=2->1]
2+
Warnings:
3+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
5+
# DROP slave_master_info table and re-create it as of MySQL 5.6.30
6+
[connection server_1]
7+
CALL mtr.add_suppression('A slave with the same server_uuid/server_id as this slave has connected to the master');
8+
include/stop_slave.inc
9+
USE mysql;
10+
DROP TABLE `slave_master_info`;
11+
CREATE TABLE `slave_master_info` (
12+
`Number_of_lines` INT(10) UNSIGNED NOT NULL COMMENT 'Number of lines in the file.',
13+
`Master_log_name` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of the master binary log currently being read from the master.',
14+
`Master_log_pos` bigint(20) UNSIGNED NOT NULL COMMENT 'The master log position of the last read event.',
15+
`Host` CHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',
16+
`User_name` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
17+
`User_password` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
18+
`Port` INT(10) UNSIGNED NOT NULL COMMENT 'The network port used to connect to the master.',
19+
`Connect_retry` INT(10) UNSIGNED NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
20+
`Enabled_ssl` TINYINT(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
21+
`Ssl_ca` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
22+
`Ssl_capath` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
23+
`Ssl_cert` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
24+
`Ssl_cipher` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
25+
`Ssl_key` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
26+
`Ssl_verify_server_cert` TINYINT(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
27+
`Heartbeat` FLOAT NOT NULL,
28+
`Bind` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
29+
`Ignored_server_ids` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs to be ignored, followed by the actual server IDs',
30+
`Uuid` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
31+
`Retry_count` BIGINT(20) UNSIGNED NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
32+
`Ssl_crl` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
33+
`Ssl_crlpath` TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
34+
`Enabled_auto_position` TINYINT(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
35+
PRIMARY KEY (`Host`,`Port`)
36+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
37+
# Running mysql_upgrade to update slave_master_info table
38+
mysql.columns_priv OK
39+
mysql.db OK
40+
mysql.engine_cost OK
41+
mysql.event OK
42+
mysql.func OK
43+
mysql.general_log OK
44+
mysql.gtid_executed OK
45+
mysql.help_category OK
46+
mysql.help_keyword OK
47+
mysql.help_relation OK
48+
mysql.help_topic OK
49+
mysql.innodb_index_stats OK
50+
mysql.innodb_table_stats OK
51+
mysql.ndb_binlog_index OK
52+
mysql.plugin OK
53+
mysql.proc OK
54+
mysql.procs_priv OK
55+
mysql.proxies_priv OK
56+
mysql.server_cost OK
57+
mysql.servers OK
58+
mysql.slave_master_info OK
59+
mysql.slave_relay_log_info OK
60+
mysql.slave_worker_info OK
61+
mysql.slow_log OK
62+
mysql.tables_priv OK
63+
mysql.time_zone OK
64+
mysql.time_zone_leap_second OK
65+
mysql.time_zone_name OK
66+
mysql.time_zone_transition OK
67+
mysql.time_zone_transition_type OK
68+
mysql.user OK
69+
mtr.global_suppressions OK
70+
mtr.test_suppressions OK
71+
sys.sys_config OK
72+
include/rpl_restart_server.inc [server_number=1]
73+
[connection server_1]
74+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT FOR CHANNEL 'channel_1';
75+
Warnings:
76+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
77+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
78+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT FOR CHANNEL 'channel_2';
79+
Warnings:
80+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
81+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
82+
include/assert.inc [Default channel name is '']
83+
include/assert.inc [Second channel name is 'channel_1']
84+
include/assert.inc [Third channel name is 'channel_2']
85+
include/stop_slave.inc
86+
Warnings:
87+
Note 3084 Replication thread(s) for channel 'channel_1' are already stopped.
88+
Note 3084 Replication thread(s) for channel 'channel_2' are already stopped.
89+
RESET SLAVE ALL;
90+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT;
91+
Warnings:
92+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
93+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
94+
include/start_slave.inc
95+
[connection server_2]
96+
CREATE TABLE t1 (c1 INT);
97+
INSERT INTO t1 VALUES (1);
98+
include/save_master_pos.inc
99+
[connection server_1]
100+
include/sync_slave_sql.inc
101+
ALTER TABLE slave_master_info
102+
MODIFY Host CHAR(64) CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT 'The host name of the master.',
103+
ALTER COLUMN Channel_name DROP DEFAULT;
104+
include/stop_slave.inc
105+
CALL mtr.add_suppression('Info table has a problem with its key field.*slave_master_info');
106+
CALL mtr.add_suppression('Error in checking mysql.slave_master_info repository info type of TABLE');
107+
CALL mtr.add_suppression('Error creating master info');
108+
ALTER TABLE slave_master_info
109+
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
110+
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication'
111+
AFTER Tls_version;
112+
RESET SLAVE ALL;
113+
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
114+
include/assert_grep.inc [Found the expected error line in the error log.]
115+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT;
116+
ERROR HY000: Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
117+
START SLAVE;
118+
ERROR HY000: Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
119+
ALTER TABLE slave_master_info
120+
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
121+
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication'
122+
AFTER Enabled_auto_position;
123+
include/rpl_restart_server.inc [server_number=1]
124+
RESET SLAVE ALL;
125+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_LOG_FILE='FILE', MASTER_LOG_POS=POS;
126+
Warnings:
127+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
128+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
129+
include/start_slave.inc
130+
CALL mtr.add_suppression('Failed to create a channel from master info table repository');
131+
CALL mtr.add_suppression('Could not create channel list');
132+
CALL mtr.add_suppression('Failed to create or recover replication info repositories');
133+
[connection server_2]
134+
INSERT INTO t1 VALUES (2);
135+
include/sync_slave_sql_with_master.inc
136+
include/stop_slave.inc
137+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_LOG_FILE='FILE', MASTER_LOG_POS=POS FOR CHANNEL 'channel_1';
138+
Warnings:
139+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
140+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
141+
include/start_slave.inc
142+
[connection server_2]
143+
INSERT INTO t1 VALUES (3);
144+
include/sync_slave_sql_with_master.inc
145+
include/stop_slave.inc
146+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_LOG_FILE='FILE', MASTER_LOG_POS=POS FOR CHANNEL 'channel_2';
147+
Warnings:
148+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
149+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
150+
include/start_slave.inc
151+
[connection server_2]
152+
INSERT INTO t1 VALUES (4);
153+
include/sync_slave_sql_with_master.inc
154+
include/stop_slave.inc
155+
ALTER TABLE slave_master_info
156+
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
157+
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication'
158+
AFTER Tls_version;
159+
include/rpl_restart_server.inc [server_number=1]
160+
RESET SLAVE ALL;
161+
ERROR HY000: Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
162+
include/assert_grep.inc [Found the expected error line in the error log generated on server startup.]
163+
ALTER TABLE slave_master_info
164+
MODIFY Channel_name CHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
165+
COMMENT 'The channel on which the slave is connected to a source. Used in Multisource Replication'
166+
AFTER Enabled_auto_position;
167+
include/rpl_restart_server.inc [server_number=1]
168+
include/stop_slave.inc
169+
RESET SLAVE ALL;
170+
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_LOG_FILE='FILE', MASTER_LOG_POS=POS;
171+
Warnings:
172+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
173+
Note 1760 Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
174+
include/start_slave.inc
175+
[connection server_2]
176+
DROP TABLE t1;
177+
include/rpl_end.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--master-info-repository=TABLE
2+
--relay-log-info-repository=TABLE
3+
--log_error=$MYSQLTEST_VARDIR/tmp/slave.err
4+
--no-console

0 commit comments

Comments
 (0)