1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
--echo #
--echo # WL-13689 Use signal SIGUSR1 to flush logs
--echo #
--echo # Use signal SIGUSR1 to be a light version of SIGHUP.
--echo # The signal is needed to have a reliable
--echo # way to flush logs in mysql. This will include error log,
--echo # general log and slow query log.
--echo #
--echo # This test will cover, that the signal is sent corectly, meaning that:
--echo # When SIGUSR1 is sent:
--echo # Logs are empty afterwards.
--echo # Logs can be written to afterwards.
--echo # Test involves sending SIGUSR1 signal from perl.
--source include/not_windows.inc
--echo #################################################################
--echo ############### ERROR LOG ################################
--let MYSQLD_LOG= $MYSQL_TMP_DIR/sigusr1_test.log
--let MYSQLD_LOG_SLOW= $MYSQL_TMP_DIR/sigusr1_test_slow.log
--let MYSQLD_LOG_GENERAL= $MYSQL_TMP_DIR/sigusr1_test_general.log
--let $restart_parameters=restart:--log-error=$MYSQLD_LOG --general_log=0 --general_log_file=$MYSQLD_LOG_GENERAL --log_output=FILE --slow_query_log=0 --long_query_time=0 --slow_query_log_file=$MYSQLD_LOG_SLOW
--replace_result $MYSQLD_LOG MYSQLD_LOG $MYSQLD_LOG_SLOW MYSQLD_LOG_SLOW $MYSQLD_LOG_GENERAL MYSQLD_LOG_GENERAL
--source include/restart_mysqld.inc
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
--echo #
--echo # Send the log file into a new file that perl can fiddle with.
--echo #
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
my $wait_cnt=60;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
rename $ENV{"MYSQLD_LOG"}, $ENV{"MYSQLD_LOG"}.".1";
kill 'USR1', $pid or die "could not kill $pid: $!";
while (! -e $ENV{"MYSQLD_LOG"}) {
if($wait_cnt==0) { die "timedout waiting for general_log to be flushed"; }
sleep 1;
$wait_cnt--;
}
EOF
--echo # Check that both files still exists
--file_exists $MYSQLD_LOG
--file_exists $MYSQLD_LOG.1
--echo # CLEAN UP
--remove_file $MYSQLD_LOG.1
--echo #################################################################
--echo ############### SLOW LOG ################################
SET @@global.slow_query_log=1;
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SELECT 1;
--echo #
--echo # Send the log file into a new file that perl can fiddle with.
--echo #
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
my $wait_cnt=60;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
rename $ENV{"MYSQLD_LOG_SLOW"}, $ENV{"MYSQLD_LOG_SLOW"}.".1";
kill 'USR1', $pid or die "could not kill $pid: $!";
while (! -e $ENV{"MYSQLD_LOG_SLOW"}) {
if($wait_cnt==0) { die "timedout waiting for general_log to be flushed"; }
sleep 1;
$wait_cnt--;
}
EOF
--echo # Check that both files still exists
--file_exists $MYSQLD_LOG_SLOW
--file_exists $MYSQLD_LOG_SLOW.1
--echo #
--echo # Set the log output to a table.
--echo # The server must not fail when SIGUSR1 is sent, even though slow log output
--echo # is set to a table (log_output).
--echo #
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SET @@global.log_output='TABLE';
SELECT 1;
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
kill 'USR1', $pid or die "could not kill $pid: $!";
EOF
--echo #
--echo # SET LOG OUTPUT TO 'NONE'
--echo #
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SET @@global.log_output='NONE';
SELECT 1;
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
kill 'USR1', $pid or die "could not kill $pid: $!";
EOF
--echo # CLEAN UP
SET @@global.slow_query_log=0;
--remove_file $MYSQLD_LOG_SLOW
--remove_file $MYSQLD_LOG_SLOW.1
--echo #################################################################
--echo ############### GENERAL LOG ################################
SET @@global.general_log=1;
SET @@global.log_output='FILE';
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SELECT 1;
--echo #
--echo # Send the log file into a new file that perl can fiddle with.
--echo #
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
my $wait_cnt=60;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
rename $ENV{"MYSQLD_LOG_GENERAL"}, $ENV{"MYSQLD_LOG_GENERAL"}.".1";
kill 'USR1', $pid or die "could not kill $pid: $!";
while (! -e $ENV{"MYSQLD_LOG_GENERAL"}) {
if($wait_cnt==0) { die "timedout waiting for general_log to be flushed"; }
sleep 1;
$wait_cnt--;
}
EOF
--echo # Check that both files still exists
--file_exists $MYSQLD_LOG_GENERAL
--file_exists $MYSQLD_LOG_GENERAL.1
--echo #
--echo # Set the log output to a table.
--echo # The server must not fail when SIGUSR1 is sent, even though slow log output
--echo # is set to a table (log_output).
--echo # let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SET @@global.log_output='TABLE';
SELECT 1;
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
kill 'USR1', $pid or die "could not kill $pid: $!";
EOF
--echo #
--echo # SET LOG OUTPUT TO 'NONE'
--echo #
let MYSQLD_PIDFILE= `SELECT @@pid_file;`;
SET @@global.log_output='NONE';
SELECT 1;
--perl
use strict;
use warnings;
my $filename = $ENV{"MYSQLD_PIDFILE"} or die("pidfile not set");
my $pid;
open(FILE, "$filename") or die "cannot open file $filename";
while(<FILE>) {
$pid = $_;
}
close(FILE);
kill 'USR1', $pid or die "could not kill $pid: $!";
EOF
--echo # CLEAN UP
SET @@global.general_log=0;
TRUNCATE TABLE mysql.general_log;
TRUNCATE TABLE mysql.slow_log;
--echo # Restore default settings
--let $restart_parameters = restart:
--source include/restart_mysqld.inc
--remove_file $MYSQLD_LOG
--remove_file $MYSQLD_LOG_GENERAL
--remove_file $MYSQLD_LOG_GENERAL.1
|