Skip to content

Commit c1efad2

Browse files
author
Anushree Prakash B
committed
Bug#24384561 - 5.7.14 COMPLAINS ABOUT WRONG
SLAVE_MASTER_INFO AFTER UPGRADE FROM 5.7.13 DESCRIPTION =========== After upgrading from 5.6.21 to 5.7.13 and then to 5.7.14, the mysql.slave_master_info table reports an error that the fields 'Channel_name' and 'Tls_version' are not in the expected order. ANALYSIS ======== It is expected that the column Tls_version comes after column Channel_name in the slave_master_info table. When upgrade happens from 5.6.21 directly to the 5.7.13+ release, these fields which were not present earlier are added in a correct order. The columns Channel_name and Tls_version are present in an incorrect order in 5.7.13. So, when the upgrade happens from 5.7.13 to 5.7.13+, the upgrade tool does not correct its order resulting in reporting an error in 5.7.13+ release. FIX === The upgrade script should correct the order of the columns Channel_name and Tls_version in the slave_master_info table if the order was incorrect.
1 parent 3017cc2 commit c1efad2

File tree

3 files changed

+305
-0
lines changed

3 files changed

+305
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
USE test;
2+
CREATE TABLE test.slave_master_info_backup LIKE mysql.slave_master_info;
3+
INSERT INTO test.slave_master_info_backup SELECT * FROM mysql.slave_master_info;
4+
USE mysql;
5+
CREATE TABLE test.original
6+
SELECT COLUMN_NAME, ORDINAL_POSITION
7+
FROM INFORMATION_SCHEMA.COLUMNS
8+
WHERE TABLE_NAME = "slave_master_info"
9+
AND TABLE_SCHEMA = "mysql";
10+
# Scenario 1:
11+
# Verify that the upgrade script works correctly when upgrading from the same version
12+
# i.e. when both the columns Channel_name and Tls_version are in the correct order.
13+
mysql.columns_priv OK
14+
mysql.db OK
15+
mysql.engine_cost OK
16+
mysql.event OK
17+
mysql.func OK
18+
mysql.general_log OK
19+
mysql.gtid_executed OK
20+
mysql.help_category OK
21+
mysql.help_keyword OK
22+
mysql.help_relation OK
23+
mysql.help_topic OK
24+
mysql.innodb_index_stats OK
25+
mysql.innodb_table_stats OK
26+
mysql.ndb_binlog_index OK
27+
mysql.plugin OK
28+
mysql.proc OK
29+
mysql.procs_priv OK
30+
mysql.proxies_priv OK
31+
mysql.server_cost OK
32+
mysql.servers OK
33+
mysql.slave_master_info OK
34+
mysql.slave_relay_log_info OK
35+
mysql.slave_worker_info OK
36+
mysql.slow_log OK
37+
mysql.tables_priv OK
38+
mysql.time_zone OK
39+
mysql.time_zone_leap_second OK
40+
mysql.time_zone_name OK
41+
mysql.time_zone_transition OK
42+
mysql.time_zone_transition_type OK
43+
mysql.user OK
44+
mtr.global_suppressions OK
45+
mtr.test_suppressions OK
46+
sys.sys_config OK
47+
test.original OK
48+
test.slave_master_info_backup OK
49+
CREATE TABLE test.upgraded
50+
SELECT COLUMN_NAME, ORDINAL_POSITION
51+
FROM INFORMATION_SCHEMA.COLUMNS
52+
WHERE TABLE_NAME = "slave_master_info"
53+
AND TABLE_SCHEMA = "mysql";
54+
include/diff_tables.inc [test.upgraded, test.original]
55+
DROP TABLE test.upgraded;
56+
# Scenario 2:
57+
# Verify that the upgrade script corrects the order of columns Channel_name
58+
# and Tls_version in mysql.slave_master_info if the order is found to be wrong.
59+
ALTER TABLE slave_master_info
60+
MODIFY COLUMN Channel_name char(64) NOT NULL COMMENT
61+
'The channel on which the slave is connected to a source. Used in Multisource Replication'
62+
AFTER Tls_version;
63+
# Running mysql_upgrade to update slave_master_info table
64+
mysql.columns_priv OK
65+
mysql.db OK
66+
mysql.engine_cost OK
67+
mysql.event OK
68+
mysql.func OK
69+
mysql.general_log OK
70+
mysql.gtid_executed OK
71+
mysql.help_category OK
72+
mysql.help_keyword OK
73+
mysql.help_relation OK
74+
mysql.help_topic OK
75+
mysql.innodb_index_stats OK
76+
mysql.innodb_table_stats OK
77+
mysql.ndb_binlog_index OK
78+
mysql.plugin OK
79+
mysql.proc OK
80+
mysql.procs_priv OK
81+
mysql.proxies_priv OK
82+
mysql.server_cost OK
83+
mysql.servers OK
84+
mysql.slave_master_info OK
85+
mysql.slave_relay_log_info OK
86+
mysql.slave_worker_info OK
87+
mysql.slow_log OK
88+
mysql.tables_priv OK
89+
mysql.time_zone OK
90+
mysql.time_zone_leap_second OK
91+
mysql.time_zone_name OK
92+
mysql.time_zone_transition OK
93+
mysql.time_zone_transition_type OK
94+
mysql.user OK
95+
mtr.global_suppressions OK
96+
mtr.test_suppressions OK
97+
sys.sys_config OK
98+
test.original OK
99+
test.slave_master_info_backup OK
100+
# Verify that the columns Channel_name and Tls_version are now in correct order.
101+
CREATE TABLE test.upgraded
102+
SELECT COLUMN_NAME, ORDINAL_POSITION
103+
FROM INFORMATION_SCHEMA.COLUMNS
104+
WHERE TABLE_NAME = "slave_master_info"
105+
AND TABLE_SCHEMA = "mysql";
106+
include/diff_tables.inc [test.upgraded, test.original]
107+
DROP TABLE test.upgraded;
108+
# Scenario 3:
109+
# DROP slave_master_info table and re-create it as of MySQL 5.6.21
110+
DROP table slave_master_info;
111+
CREATE TABLE `slave_master_info` (
112+
`Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',
113+
`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.',
114+
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.',
115+
`Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',
116+
`User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
117+
`User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
118+
`Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.',
119+
`Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
120+
`Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
121+
`Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
122+
`Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
123+
`Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
124+
`Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
125+
`Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
126+
`Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
127+
`Heartbeat` float NOT NULL,
128+
`Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
129+
`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',
130+
`Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
131+
`Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
132+
`Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
133+
`Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
134+
`Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
135+
PRIMARY KEY (`Host`,`Port`)
136+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
137+
#Running mysql_upgrade to update slave_master_info table
138+
mysql.columns_priv OK
139+
mysql.db OK
140+
mysql.engine_cost OK
141+
mysql.event OK
142+
mysql.func OK
143+
mysql.general_log OK
144+
mysql.gtid_executed OK
145+
mysql.help_category OK
146+
mysql.help_keyword OK
147+
mysql.help_relation OK
148+
mysql.help_topic OK
149+
mysql.innodb_index_stats OK
150+
mysql.innodb_table_stats OK
151+
mysql.ndb_binlog_index OK
152+
mysql.plugin OK
153+
mysql.proc OK
154+
mysql.procs_priv OK
155+
mysql.proxies_priv OK
156+
mysql.server_cost OK
157+
mysql.servers OK
158+
mysql.slave_master_info OK
159+
mysql.slave_relay_log_info OK
160+
mysql.slave_worker_info OK
161+
mysql.slow_log OK
162+
mysql.tables_priv OK
163+
mysql.time_zone OK
164+
mysql.time_zone_leap_second OK
165+
mysql.time_zone_name OK
166+
mysql.time_zone_transition OK
167+
mysql.time_zone_transition_type OK
168+
mysql.user OK
169+
mtr.global_suppressions OK
170+
mtr.test_suppressions OK
171+
sys.sys_config OK
172+
test.original OK
173+
test.slave_master_info_backup OK
174+
#Verify that the columns Channel_name and Tls_version are added and are in correct order.
175+
CREATE TABLE test.upgraded
176+
SELECT COLUMN_NAME, ORDINAL_POSITION
177+
FROM INFORMATION_SCHEMA.COLUMNS
178+
WHERE TABLE_NAME = "slave_master_info"
179+
AND TABLE_SCHEMA = "mysql";
180+
include/diff_tables.inc [test.upgraded, test.original]
181+
DROP TABLE test.upgraded;
182+
DROP TABLE mysql.slave_master_info;
183+
RENAME TABLE test.slave_master_info_backup TO mysql.slave_master_info;
184+
DROP TABLE test.original;
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# === Purpose ===
2+
#
3+
# This test case will verify that the mysql_upgrade script
4+
# corrects the order of the columns Channel_name and Tls_version
5+
# in the table mysql.slave_master_info if their order was wrong.
6+
# In case of mysql_upgrade happening from a release where the above
7+
# two columns are not present in the table, the test case certifies
8+
# that the upgrade script adds them in the correct order.
9+
#
10+
# ==== Related Bugs and Worklogs ====
11+
#
12+
# Bug #24384561: 5.7.14 COMPLAINS ABOUT WRONG
13+
# SLAVE_MASTER_INFO AFTER UPGRADE FROM 5.7.13
14+
#
15+
16+
--source include/mysql_upgrade_preparation.inc
17+
USE test;
18+
19+
# Preserve the original state of the table so that it can be restored at the end of the test.
20+
CREATE TABLE test.slave_master_info_backup LIKE mysql.slave_master_info;
21+
INSERT INTO test.slave_master_info_backup SELECT * FROM mysql.slave_master_info;
22+
23+
USE mysql;
24+
CREATE TABLE test.original
25+
SELECT COLUMN_NAME, ORDINAL_POSITION
26+
FROM INFORMATION_SCHEMA.COLUMNS
27+
WHERE TABLE_NAME = "slave_master_info"
28+
AND TABLE_SCHEMA = "mysql";
29+
30+
--echo # Scenario 1:
31+
--echo # Verify that the upgrade script works correctly when upgrading from the same version
32+
--echo # i.e. when both the columns Channel_name and Tls_version are in the correct order.
33+
--exec $MYSQL_UPGRADE --skip-verbose --skip-sys-schema --force 2>&1
34+
35+
CREATE TABLE test.upgraded
36+
SELECT COLUMN_NAME, ORDINAL_POSITION
37+
FROM INFORMATION_SCHEMA.COLUMNS
38+
WHERE TABLE_NAME = "slave_master_info"
39+
AND TABLE_SCHEMA = "mysql";
40+
--let $diff_tables= test.upgraded, test.original
41+
--source include/diff_tables.inc
42+
DROP TABLE test.upgraded;
43+
44+
--echo # Scenario 2:
45+
--echo # Verify that the upgrade script corrects the order of columns Channel_name
46+
--echo # and Tls_version in mysql.slave_master_info if the order is found to be wrong.
47+
48+
ALTER TABLE slave_master_info
49+
MODIFY COLUMN Channel_name char(64) NOT NULL COMMENT
50+
'The channel on which the slave is connected to a source. Used in Multisource Replication'
51+
AFTER Tls_version;
52+
53+
--echo # Running mysql_upgrade to update slave_master_info table
54+
--exec $MYSQL_UPGRADE --skip-verbose --skip-sys-schema --force 2>&1
55+
56+
--echo # Verify that the columns Channel_name and Tls_version are now in correct order.
57+
CREATE TABLE test.upgraded
58+
SELECT COLUMN_NAME, ORDINAL_POSITION
59+
FROM INFORMATION_SCHEMA.COLUMNS
60+
WHERE TABLE_NAME = "slave_master_info"
61+
AND TABLE_SCHEMA = "mysql";
62+
--let $diff_tables= test.upgraded, test.original
63+
--source include/diff_tables.inc
64+
DROP TABLE test.upgraded;
65+
66+
--echo # Scenario 3:
67+
--echo # DROP slave_master_info table and re-create it as of MySQL 5.6.21
68+
69+
DROP table slave_master_info;
70+
71+
CREATE TABLE `slave_master_info` (
72+
`Number_of_lines` int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',
73+
`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.',
74+
`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last read event.',
75+
`Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'The host name of the master.',
76+
`User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connect to the master.',
77+
`User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connect to the master.',
78+
`Port` int(10) unsigned NOT NULL COMMENT 'The network port used to connect to the master.',
79+
`Connect_retry` int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave will wait before trying to reconnect to the master.',
80+
`Enabled_ssl` tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSL connections.',
81+
`Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Authority (CA) certificate.',
82+
`Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the Certificate Authority (CA) certificates.',
83+
`Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL certificate file.',
84+
`Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in use for the SSL connection.',
85+
`Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL key file.',
86+
`Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
87+
`Heartbeat` float NOT NULL,
88+
`Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface is employed when connecting to the MySQL server',
89+
`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',
90+
`Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
91+
`Retry_count` bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to the master, before giving up.',
92+
`Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for the Certificate Revocation List (CRL)',
93+
`Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for Certificate Revocation List (CRL) files',
94+
`Enabled_auto_position` tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieve events from the master.',
95+
PRIMARY KEY (`Host`,`Port`)
96+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Master Information';
97+
98+
--echo #Running mysql_upgrade to update slave_master_info table
99+
--exec $MYSQL_UPGRADE --skip-verbose --skip-sys-schema --force 2>&1
100+
101+
--echo #Verify that the columns Channel_name and Tls_version are added and are in correct order.
102+
CREATE TABLE test.upgraded
103+
SELECT COLUMN_NAME, ORDINAL_POSITION
104+
FROM INFORMATION_SCHEMA.COLUMNS
105+
WHERE TABLE_NAME = "slave_master_info"
106+
AND TABLE_SCHEMA = "mysql";
107+
--let $diff_tables= test.upgraded, test.original
108+
--source include/diff_tables.inc
109+
DROP TABLE test.upgraded;
110+
111+
# Cleanup:
112+
DROP TABLE mysql.slave_master_info;
113+
RENAME TABLE test.slave_master_info_backup TO mysql.slave_master_info;
114+
DROP TABLE test.original;
115+
--source include/mysql_upgrade_cleanup.inc

scripts/mysql_system_tables_fix.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,12 @@ ALTER TABLE slave_worker_info
827827
# The Tls_version field at slave_master_info should be added after the Channel_name field
828828
ALTER TABLE slave_master_info ADD Tls_version TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Tls version';
829829

830+
# If the order of columns Channel_name and Tls_version is wrong, this will correct the order
831+
# in slave_master_info table.
832+
ALTER TABLE slave_master_info
833+
MODIFY COLUMN Tls_version TEXT CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Tls version'
834+
AFTER Channel_name;
835+
830836
SET @have_innodb= (SELECT COUNT(engine) FROM information_schema.engines WHERE engine='InnoDB' AND support != 'NO');
831837
SET @str=IF(@have_innodb <> 0, "ALTER TABLE innodb_table_stats STATS_PERSISTENT=0", "SET @dummy = 0");
832838
PREPARE stmt FROM @str;

0 commit comments

Comments
 (0)