1
############################################################################
2
# Test kill-long-queries and kill-long-queries-timeout optins
3
############################################################################
24
function mysql_select()
26
vlog "Run select query with duration $1 seconds"
27
${MYSQL} ${MYSQL_ARGS} -c test 2> /dev/null <<EOF
28
/* Run background /*SELECT*\ */
30
SELECT SLEEP($1) FROM t1 FOR UPDATE
38
function mysql_update()
40
vlog "Run update query with duration $1 seconds"
41
${MYSQL} ${MYSQL_ARGS} -c test 2> /dev/null <<EOF
42
/* This is not SELECT but rather an /*UPDATE*\
44
UPDATE t1 SET a = SLEEP($1);
51
vlog "Killing $1, expecting it is alive"
58
vlog "Waiting for $1, expecting it's success"
63
function bg_wait_fail()
65
vlog "Waiting for $1, expecting it would fail"
66
run_cmd_expect_failure wait $1
69
function kill_all_queries()
71
run_cmd $MYSQL $MYSQL_ARGS test <<EOF
72
select concat('KILL ',id,';') from information_schema.processlist
73
where user='root' and time > 2 into outfile '$MYSQLD_TMPDIR/killall.sql';
74
source $MYSQLD_TMPDIR/killall.sql;
76
rm -f $MYSQLD_TMPDIR/killall.sql
79
start_server --innodb_file_per_table
81
run_cmd $MYSQL $MYSQL_ARGS test <<EOF
82
CREATE TABLE t1(a INT) ENGINE=InnoDB;
83
INSERT INTO t1 VALUES (1);
88
# ==============================================================
89
vlog "===================== case 1 ====================="
90
bg_run bg_select_pid "mysql_select 3"
91
bg_run bg_update_pid "sleep 1" "mysql_update 3"
93
innobackupex $topdir/full --kill-long-queries-timeout=5 \
94
--kill-long-query-type=all
96
bg_wait_ok $bg_select_pid
97
bg_wait_ok $bg_update_pid
101
# ==============================================================
102
vlog "===================== case 2 ====================="
103
bg_run bg_select_pid "mysql_select 200"
104
bg_run bg_update_pid "sleep 1" "mysql_update 5"
106
innobackupex $topdir/full --kill-long-queries-timeout=3 \
107
--kill-long-query-type=select
109
bg_wait_fail $bg_select_pid
110
bg_wait_ok $bg_update_pid
114
# ==============================================================
115
vlog "===================== case 3 ====================="
116
bg_run bg_select_pid "mysql_select 200"
117
bg_run bg_update_pid "mysql_update 200"
119
innobackupex $topdir/full --kill-long-queries-timeout=3 \
120
--kill-long-query-type=all
122
bg_wait_fail $bg_select_pid
123
bg_wait_fail $bg_update_pid
127
# ==============================================================
128
vlog "===================== case 4 ====================="
129
bg_run bg_select_pid "mysql_select 200"
130
bg_run bg_update_pid "mysql_update 200"
134
run_cmd_expect_failure ${IB_BIN} ${IB_ARGS} $topdir/full \
135
--lock-wait-timeout=3 \
136
--lock-wait-query-type=all \
137
--lock-wait-threshold=1 \
138
--kill-long-queries-timeout=1 \
139
--kill-long-query-type=all
141
bg_kill_ok $bg_select_pid
142
bg_kill_ok $bg_update_pid
146
# ==============================================================
147
vlog "===================== case 5 ====================="
148
bg_run bg_select_pid "mysql_select 200"
149
bg_run bg_update_pid "mysql_update 200"
153
run_cmd_expect_failure ${IB_BIN} ${IB_ARGS} $topdir/full \
154
--lock-wait-timeout=3 \
155
--lock-wait-query-type=update \
156
--lock-wait-threshold=2 \
157
--kill-long-queries-timeout=1 \
158
--kill-long-query-type=all
160
bg_kill_ok $bg_select_pid
161
bg_kill_ok $bg_update_pid
165
# ==============================================================
166
vlog "===================== case 6 ====================="
167
bg_run bg_update_pid "mysql_update 5"
168
bg_run bg_select_pid "sleep 1" "mysql_select 200"
172
innobackupex $topdir/full \
173
--lock-wait-timeout=6 \
174
--lock-wait-query-type=update \
175
--lock-wait-threshold=2 \
176
--kill-long-queries-timeout=1 \
177
--kill-long-query-type=all
179
bg_wait_fail $bg_select_pid
180
bg_wait_ok $bg_update_pid