Debian Codegraph @

mysql-test/suite/rpl/t/rpl_shutdown_sighup.test

raw
1 #
2 # The signal handler thread can use various different runtime resources when
3 # processing a SIGHUP (e.g. master-info information), as the logic calls into
4 # reload_acl_and_cache(). This test ensures that SIGHUP processing, when
5 # concurrent with server shutdown, the shutdown logic must wait for the SIGHUP
6 # processing to finish before cleaning up any resources.
7 #
8 # Additionally, the error case is tested such that the signal handler thread
9 # takes too long processing a SIGHUP, and the main mysqld thread must skip its
10 # wait and output a warning.
11 #
12 # Note the SIGHUP is sent via the command-line kill program via a perl script.
13 #
14 # References:
15 # MDEV-30260: Slave crashed:reload_acl_and_cache during shutdown
16 #
17
18 --source include/not_windows.inc
19 --source include/not_embedded.inc
20 --source include/have_debug.inc
21 --source include/have_debug_sync.inc
22
23 # Binlog format doesn't matter
24 --source include/have_binlog_format_statement.inc
25 --source include/master-slave.inc
26
27 # For error test case which forces timeout
28 --connection slave
29 set statement sql_log_bin=0 for call mtr.add_suppression("Signal handler thread did not exit in a timely manner");
30
31
32 --echo #
33 --echo # Main test
34 --connection master
35 create table t1 (a int);
36 insert into t1 values (1);
37 --source include/save_master_gtid.inc
38
39 --connection slave
40 --source include/sync_with_master_gtid.inc
41
42 # Make signal handler handle SIGHUP..
43 set @@global.debug_dbug= "+d,hold_sighup_log_refresh";
44 --let KILL_NODE_PIDFILE = `SELECT @@pid_file`
45 --perl
46 my $kill_sig = $ENV{'KILL_SIGNAL_VALUE'};
47 my $pid_filename = $ENV{'KILL_NODE_PIDFILE'};
48 my $mysqld_pid = `cat $pid_filename`;
49 chomp($mysqld_pid);
50 system("kill -HUP $mysqld_pid");
51 exit(0);
52 EOF
53
54 --echo # Waiting for sighup to reach reload_acl_and_cache..
55 set debug_sync="now wait_for in_reload_acl_and_cache";
56 --echo # Signalling signal handler to proceed to sleep before REFRESH_HOSTS
57 set debug_sync="now signal refresh_logs";
58
59 # ..while we are shutting down
60 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
61 wait
62 EOF
63 --echo # Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache)
64 shutdown;
65
66 --source include/wait_until_disconnected.inc
67 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
68 restart: --skip-slave-start=0
69 EOF
70
71 --connection server_2
72 --enable_reconnect
73 --source include/wait_until_connected_again.inc
74
75 --connection slave
76 --enable_reconnect
77 --source include/wait_until_connected_again.inc
78
79 --let $assert_text= Ensure Mariadbd did not segfault when shutting down
80 --let $assert_select= got signal 11
81 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
82 --let $assert_count= 0
83 --let $assert_only_after = CURRENT_TEST: rpl.rpl_shutdown_sighup
84 --source include/assert_grep.inc
85
86 --connection master
87 --sync_slave_with_master
88
89
90 --echo #
91 --echo # Error testcase to ensure an error message is shown if the signal
92 --echo # takes longer than the timeout while processing the SIGHUP
93
94 --connection slave
95 set @@global.debug_dbug= "+d,force_sighup_processing_timeout";
96 set @@global.debug_dbug= "+d,hold_sighup_log_refresh";
97
98 --connection master
99 insert into t1 values (1);
100 --source include/save_master_gtid.inc
101
102 --connection slave
103 --source include/sync_with_master_gtid.inc
104
105 # Make signal handler handle SIGHUP..
106 --let KILL_NODE_PIDFILE = `SELECT @@pid_file`
107 --perl
108 my $kill_sig = $ENV{'KILL_SIGNAL_VALUE'};
109 my $pid_filename = $ENV{'KILL_NODE_PIDFILE'};
110 my $mysqld_pid = `cat $pid_filename`;
111 chomp($mysqld_pid);
112 system("kill -HUP $mysqld_pid");
113 exit(0);
114 EOF
115 --echo # Waiting for sighup to reach reload_acl_and_cache..
116 set debug_sync="now wait_for in_reload_acl_and_cache";
117 --echo # Signalling signal handler to proceed to sleep before REFRESH_HOSTS
118 set debug_sync="now signal refresh_logs";
119
120 # ..while we are shutting down
121 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
122 wait
123 EOF
124 --echo # Starting shutdown (note this will take 3+ seconds due to DBUG my_sleep in reload_acl_and_cache)
125 shutdown;
126
127 --source include/wait_until_disconnected.inc
128 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
129 restart: --skip-slave-start=0
130 EOF
131
132 --connection server_2
133 --enable_reconnect
134 --source include/wait_until_connected_again.inc
135
136 --connection slave
137 --enable_reconnect
138 --source include/wait_until_connected_again.inc
139
140 --let $assert_text= Ensure warning is issued that signal handler thread is still processing
141 --let $assert_select= Signal handler thread did not exit in a timely manner.
142 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
143 --let $assert_count= 1
144 --let $assert_only_after = CURRENT_TEST: rpl.rpl_shutdown_sighup
145 --source include/assert_grep.inc
146
147
148 --echo #
149 --echo # Cleanup
150 --connection master
151 drop table t1;
152
153 --source include/rpl_end.inc
154 --echo # End of rpl_shutdown_sighup.test