Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_slave_server_id_equal_to_zero.test

raw
1 # ==== Purpose ====
2 #
3 # This test case verify if a server will throw the proper error when
4 # trying to configure it as a slave and start slave's threads when it's
5 # server-id is 0.
6 #
7 # The "Part One" of the test case will have a slave started with
8 # server_id > 0 but will be tested also after setting @@GLOBAL.server_id
9 # to 0.
10 #
11 # The "Part Two" of the test case will have a slave started with
12 # server_id = 0 but will be tested also after setting @@GLOBAL.server_id
13 # to a value greater than 0. In case server is configured with server_id
14 # equal to 0, but @@GLOBAL.server_id was set with the 'PERSIST' option,
15 # replica should be initialized according to the persistent variable
16 # value.
17 #
18 # Both parts are testing the default replication channel and a new
19 # replication channel in order to evaluate also the multi source slave.
20 #
21 # ==== Related Bugs and Worklogs ====
22 #
23 # BUG#20753463 HANDLE_FATAL_SIGNAL (SIG=11) IN __STRLEN_SSE2_PMINUB ON
24 # CHANGE MASTER
25 #
26 # Bug #34412816 Replication ignores the true value of server-id
27 #
28 # This test case is binlog format agnostic
29 --source include/have_binlog_format_row.inc
30 # Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE
31 --source include/have_slave_repository_type_table.inc
32 # This test case does not depend on GTID
33 --source include/master-slave.inc
34
35 # Assert that the slave was started with server_id > 0
36 --source include/rpl_connection_slave.inc
37 CALL mtr.add_suppression('Server id not set, will not start replica');
38 CALL mtr.add_suppression('Replica is not configured or failed to initialize properly');
39 --let $assert_text= slave's server_id was greater than 0 at startup
40 --let $assert_cond= [ SELECT @@GLOBAL.server_id > 0 ]
41 --source include/assert.inc
42 --let $original_slave_server_id= `SELECT @@GLOBAL.server_id`
43
44 # Replication runs fine
45 --source include/rpl_connection_master.inc
46 CREATE TABLE t1 (c1 INT) ENGINE=InnoDB;
47 --source include/sync_slave_sql_with_master.inc
48
49 ##
50 ## Part One: Server initialized slave at startup (server_id > 0)
51 ##
52
53 # Change slave @@GLOBAL.server_id to 0
54 --source include/stop_slave.inc
55 SET @@GLOBAL.server_id= 0;
56
57 # Start slave should fail
58 --error ER_BAD_REPLICA
59 START SLAVE;
60
61 # Assert that the reason of the failure was the server_id=0
62 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
63 --let $assert_text= Slave didn't started because of server_id=0
64 --let $assert_select= \[ERROR\] \[[^]]*\] \[[^]]*\] Server id not set, will not start replica for channel \'\'
65 --let $assert_count= 1
66 --source include/assert_grep.inc
67
68 # Change master still works
69 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4;
70
71 # Start slave for channel should fail
72 --error ER_REPLICA_CHANNEL_DOES_NOT_EXIST
73 START SLAVE FOR CHANNEL 'any_channel';
74
75 # Change master still works and will create the channel
76 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4, SOURCE_HOST='127.0.0.1' FOR CHANNEL 'any_channel';
77
78 # Start slave for channel should fail
79 --error ER_BAD_REPLICA
80 START SLAVE FOR CHANNEL 'any_channel';
81
82 # Assert that the reason of the failure was the server_id=0
83 --let $assert_text= Slave for channel didn't started because of server_id=0
84 --let $assert_select= \[ERROR\] \[[^]]*\] \[[^]]*\] Server id not set, will not start replica for channel \'any_channel\'
85 --let $assert_count= 1
86 --source include/assert_grep.inc
87
88 # Remove the created channel
89 RESET SLAVE ALL FOR CHANNEL 'any_channel';
90
91 # Remove the t1 table on slave to allow it to be replicated again
92 DROP TABLE t1;
93
94 # Restore slave's server_id and start slave again
95 --eval SET @@GLOBAL.server_id= $original_slave_server_id
96 --source include/start_slave.inc
97 --source include/rpl_connection_master.inc
98 --source include/sync_slave_sql_with_master.inc
99
100 ##
101 ## Part Two: Server didn't initialized slave at startup (server_id = 0)
102 ##
103
104 # Restart the slave with server_id=0
105 --let $rpl_server_number= 2
106 --let $rpl_server_parameters= --server-id=0
107 --source include/rpl_restart_server.inc
108
109 # Assert that the slave was started with server_id=0
110 --source include/rpl_connection_slave.inc
111 --let $assert_text= slave's server_id was 0 at startup
112 --let $assert_cond= [ SELECT @@GLOBAL.server_id = 0 ]
113 --source include/assert.inc
114
115 # Start slave should fail as not configured
116 --error ER_REPLICA_CONFIGURATION
117 START SLAVE;
118
119 # Change master should fail as slave not configured
120 --error ER_REPLICA_CONFIGURATION
121 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4;
122
123 # Start slave for channel should fail as not configured
124 --error ER_REPLICA_CONFIGURATION
125 START SLAVE FOR CHANNEL 'any_channel';
126
127 # Change master for channel should fail as slave not configured
128 --error ER_REPLICA_CONFIGURATION
129 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4 FOR CHANNEL 'any_channel';
130
131 # Set original slave's server_id into @@GLOBAL.server_id
132 --eval SET @@GLOBAL.server_id= $original_slave_server_id
133
134 # Start slave should still fail as not configured
135 --error ER_REPLICA_CONFIGURATION
136 START SLAVE;
137
138 # Change master should still fail as slave not configured
139 --error ER_REPLICA_CONFIGURATION
140 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4;
141
142 # Start slave for channel should still fail as not configured
143 --error ER_REPLICA_CONFIGURATION
144 START SLAVE FOR CHANNEL 'any_channel';
145
146 # Change master for channel should still fail as slave not configured
147 --error ER_REPLICA_CONFIGURATION
148 CHANGE REPLICATION SOURCE TO SOURCE_LOG_POS=4 FOR CHANNEL 'any_channel';
149
150 # Set server_id to 0 with PERSIST option
151 SET PERSIST server_id=2;
152
153 # Restart the server with server_id=0
154 --let $rpl_server_number= 2
155 --let $rpl_server_parameters= --server-id=0 --skip_replica_start=0
156 --source include/rpl_restart_server.inc
157 --source include/check_slave_is_running.inc
158 --source include/check_slave_no_error.inc
159
160 ##
161 ## Cleanup
162 ##
163
164 # Master cleanup
165 --source include/rpl_connection_master.inc
166 DROP TABLE t1;
167 --source include/rpl_end.inc