Skip to content

Commit 1cf852d

Browse files
committed
MDEV-9383: Server fails to read master.info after upgrade 10.0 -> 10.1
In some cases, MariaDB 10.0 could write a master.info file that was read incorrectly by 10.1 and could cause server to fail to start after an upgrade. (If writing a new master.info file that is shorter than the old, extra junk may remain at the end of the file. This is handled properly in 10.1 with an END_MARKER line, but this line is not written by 10.0. The fix here is to make 10.1 robust at reading the master.info files written by 10.0). Fix several things around reading master.info and read_mi_key_from_file(): - read_mi_key_from_file() did not distinguish between a line with and without an eqals '=' sign. - If a line was empty, read_mi_key_from_file() would incorrectly return the key from the previous call. - An extra using_gtid=X line left-over by MariaDB 10.0 might incorrectly be read and overwrite the correct value. - Fix incorrect usage of strncmp() which should be strcmp(). - Add test cases.
1 parent 3f61251 commit 1cf852d

File tree

9 files changed

+512
-33
lines changed

9 files changed

+512
-33
lines changed

mysql-test/std_data/bad2_master.info

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
=0

mysql-test/std_data/bad3_master.info

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
36+
37+
0

mysql-test/std_data/bad4_master.info

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
d=1

mysql-test/std_data/bad5_master.info

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
using_gtid

mysql-test/std_data/bad6_master.info

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
END_MARKER
36+
do_domain_ids=20 Hulubulu!!?!

mysql-test/std_data/bad_master.info

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
33
2+
mysql-bin.000001
3+
4
4+
127.0.0.1
5+
root
6+
7+
3310
8+
60
9+
0
10+
11+
12+
13+
14+
15+
0
16+
1800.000
17+
18+
0
19+
20+
0
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
using_gtid=1
35+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
include/master-slave.inc
2+
[connection master]
3+
*** MDEV-9383: Server fails to read master.info after upgrade 10.0 -> 10.1 ***
4+
include/stop_slave.inc
5+
CHANGE MASTER TO master_use_gtid=CURRENT_POS;
6+
include/rpl_stop_server.inc [server_number=2]
7+
include/rpl_start_server.inc [server_number=2]
8+
CREATE TABLE t1 (a INT PRIMARY KEY);
9+
INSERT INTO t1 VALUES (1);
10+
include/save_master_gtid.inc
11+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
12+
include/start_slave.inc
13+
include/sync_with_master_gtid.inc
14+
SELECT * FROM t1;
15+
a
16+
1
17+
include/stop_slave.inc
18+
include/rpl_stop_server.inc [server_number=2]
19+
include/rpl_start_server.inc [server_number=2]
20+
INSERT INTO t1 VALUES (2);
21+
include/save_master_gtid.inc
22+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
23+
include/start_slave.inc
24+
include/sync_with_master_gtid.inc
25+
SELECT * FROM t1 ORDER BY a;
26+
a
27+
1
28+
2
29+
include/stop_slave.inc
30+
include/rpl_stop_server.inc [server_number=2]
31+
include/rpl_start_server.inc [server_number=2]
32+
INSERT INTO t1 VALUES (3);
33+
include/save_master_gtid.inc
34+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
35+
include/start_slave.inc
36+
include/sync_with_master_gtid.inc
37+
SELECT * FROM t1 ORDER BY a;
38+
a
39+
1
40+
2
41+
3
42+
include/stop_slave.inc
43+
include/rpl_stop_server.inc [server_number=2]
44+
include/rpl_start_server.inc [server_number=2]
45+
INSERT INTO t1 VALUES (4);
46+
include/save_master_gtid.inc
47+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
48+
include/start_slave.inc
49+
include/sync_with_master_gtid.inc
50+
SELECT * FROM t1 ORDER BY a;
51+
a
52+
1
53+
2
54+
3
55+
4
56+
include/stop_slave.inc
57+
include/rpl_stop_server.inc [server_number=2]
58+
include/rpl_start_server.inc [server_number=2]
59+
INSERT INTO t1 VALUES (5);
60+
include/save_master_gtid.inc
61+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
62+
include/start_slave.inc
63+
include/sync_with_master_gtid.inc
64+
SELECT * FROM t1 ORDER BY a;
65+
a
66+
1
67+
2
68+
3
69+
4
70+
5
71+
include/stop_slave.inc
72+
include/rpl_stop_server.inc [server_number=2]
73+
include/rpl_start_server.inc [server_number=2]
74+
INSERT INTO t1 VALUES (6);
75+
include/save_master_gtid.inc
76+
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
77+
include/start_slave.inc
78+
include/sync_with_master_gtid.inc
79+
SELECT * FROM t1 ORDER BY a;
80+
a
81+
1
82+
2
83+
3
84+
4
85+
5
86+
6
87+
DROP TABLE t1;
88+
include/rpl_end.inc

0 commit comments

Comments
 (0)