Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtid_server_sighup.test

raw
1 ###############################################################################
2 # Bug #17026898 PREVIOUS GTID EVENT IS NOT WRITTEN WHEN BINLOG IS ROTATED VIA
3 # SIGHUP
4
5 # Problem: When Bin(Relay)log is rotated via SIGHUP signal, the newly generated
6 # binlog does not contain previous gtid event which is very important
7 # for processing that bin(relay)log's gtid events later.
8
9 # Fix: If reload_acl_and_cache() (which does rotation of Bin(Relay) log)
10 # is called from SIGHUP handler, then allocate temporary THD for
11 # execution of rotate bin(relay)log.
12
13 # Steps to reproduce the issue:
14 # 1) Get the server pid
15 # 2) Send Kill -1 signal (SIGHUP) signal to server pid
16 # 3) Wait until rotation is done
17 # 4) Verify the newly generated log contains prev_gtid_event
18 # 5) Restart the server to see the processing of the new log is not an issue.
19 # 6) Verify that Replication works fine at the end of the scenario
20
21 # Execute the same steps on both Master and Slave do prove that
22 # a) no problem in binary log rotation (i.e., prev_gtids_event exists)
23 # b) no problem in relay log rotation (i.e., prev_gtids event exists)
24 # c) no problem in restarting master
25 # d) no problem in restarting slave
26 # e) Replication works fine after receiving SIGHUP.
27 ###############################################################################
28
29 # Test involves sending SIGHUP signal using kill linux cmd
30 --source include/linux.inc
31
32 # Problem appears only with gtid
33
34 # Testing SIGHUP behaviour with one mode is enough
35 --source include/have_binlog_format_statement.inc
36 --source include/master-slave.inc
37
38 # Bug#23297190 :RPL_GTID_SERVER_SIGHUP AND RPL_SOURCE_POS_WAIT_AFTER_STARTUP FAILS
39 # IN VALGRIND : Increased the time interval between the connection retries.
40 --connection slave
41 --source include/stop_slave.inc
42 CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY=30, SOURCE_RETRY_COUNT=30;
43 --source include/start_slave.inc
44
45 --connection master
46 CREATE TABLE pid_table(pid_no INT);
47
48
49 # Execute above mentioned steps in two iterations
50 # Iteration 1 : Master and Iteration 2: Slave
51 --let $_rpl_server= 1
52 while ($_rpl_server <= 2)
53 {
54 --let $rpl_connection_name= server_$_rpl_server
55 --source include/rpl_connection.inc
56 --let $pid_file=`SELECT @@pid_file`
57 --replace_result $pid_file pid_file
58 --eval LOAD DATA LOCAL INFILE '$pid_file' INTO TABLE pid_table
59 # Step1: Get server pid
60 --let $server_pid=`SELECT pid_no FROM pid_table`
61
62 # Get current master binlog name
63 if ($_rpl_server == 1)
64 {
65 --let $before_sighup_log_name=query_get_value(SHOW MASTER STATUS, File, 1)
66 }
67 if ($_rpl_server == 2)
68 {
69 --let $before_sighup_log_name=query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
70 }
71
72 # Step2: send SIGHUP(signal 1) to server which will rotate bin(relay)log
73 --exec kill -1 $server_pid
74
75 # Step3: Wait until signal handler does required work
76 # (i.e., completes rotation of binary/relay log) after receiving SIGHUP signal.
77 if ($_rpl_server == 1)
78 {
79 --let $show_statement=SHOW MASTER STATUS
80 --let $field=File
81 }
82 if ($_rpl_server == 2)
83 {
84 --let $show_statement=SHOW SLAVE STATUS
85 --let $field=Relay_Log_File
86 }
87 --let $condition= <> '$before_sighup_log_name'
88 --source include/wait_show_condition.inc
89
90 # Write something to newly generated binary log/relay log
91 if ($_rpl_server == 2)
92 {
93 --let $rpl_connection_name= server_1
94 --source include/rpl_connection.inc
95 }
96 DELETE FROM pid_table;
97 --source include/sync_slave_sql_with_master.inc
98 if ($_rpl_server == 1)
99 {
100 --let $rpl_connection_name= server_1
101 --source include/rpl_connection.inc
102 }
103 # Step 4:Show that newly generated binary/relaylog has previous gtid event as well
104 --let $keep_gtid_events= 1
105 --let $binlog_file= LAST
106 if ($_rpl_server == 1)
107 {
108 --source include/show_binlog_events.inc
109 }
110 if ($_rpl_server == 2)
111 {
112 --source include/show_relaylog_events.inc
113 }
114 # Step5: Restart server to make sure that
115 # newly generated binary log/relay log does not cause any issues
116 --let $rpl_server_number= $_rpl_server
117 --source include/rpl_stop_server.inc
118 --let $rpl_start_with_gtids= 1
119 --source include/rpl_start_server.inc
120 if ($_rpl_server == 2)
121 {
122 --source include/rpl_start_slaves.inc
123 }
124 if ($_rpl_server == 1)
125 {
126 # We must be sure that the IO thread has connected again with the master
127 # that has just restarted, or else the results of the test case may vary.
128 # As no new GTID was generated since last sync, we will force the use of
129 # positions on the sync.
130 --let $ignore_gtids_on_sync= 1
131 --source include/sync_slave_sql_with_master.inc
132 --let $ignore_gtids_on_sync= 0
133 }
134 --inc $_rpl_server
135 }
136
137 # Now just make sure replication works fine
138 --let $rpl_connection_name= server_1
139 --source include/rpl_connection.inc
140 DROP TABLE pid_table;
141 --source include/sync_slave_sql_with_master.inc
142
143 --source include/rpl_end.inc