Commit a1fcf027 authored by mmakela's avatar mmakela

branches/5.1: Obey KILL during a lock wait (Bug #51920).

srv_suspend_mysql_thread(), srv_lock_timeout_and_monitor_thread():
Check trx_is_interrupted() in addition to checking the lock wait timeout.

rb://279 approved by Sunny Bains
parent 75bd39e0
CREATE TABLE bug51920 (i INT) ENGINE=InnoDB;
INSERT INTO bug51920 VALUES (1);
BEGIN;
SELECT * FROM bug51920 FOR UPDATE;
i
1
UPDATE bug51920 SET i=2;
SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO="UPDATE bug51920 SET i=2"
INTO @thread_id;
KILL @thread_id;
SELECT sleep(2);
sleep(2)
0
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID=@thread_id;
ID USER HOST DB COMMAND TIME STATE INFO
ERROR 70100: Query execution was interrupted
DROP TABLE bug51920;
#
# Bug #51920: InnoDB connections in lock wait ignore KILL until timeout
#
-- source include/not_embedded.inc
-- source include/have_innodb.inc
CREATE TABLE bug51920 (i INT) ENGINE=InnoDB;
INSERT INTO bug51920 VALUES (1);
BEGIN;
SELECT * FROM bug51920 FOR UPDATE;
connect (con1,localhost,root,,);
connection con1;
--send
UPDATE bug51920 SET i=2;
connection default;
SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO="UPDATE bug51920 SET i=2"
INTO @thread_id;
KILL @thread_id;
SELECT sleep(2);
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID=@thread_id;
connection con1;
-- error ER_QUERY_INTERRUPTED
reap;
connection default;
DROP TABLE bug51920;
-- disconnect con1
......@@ -1554,8 +1554,9 @@ srv_suspend_mysql_thread(
mutex_exit(&kernel_mutex);
if (srv_lock_wait_timeout < 100000000
&& wait_time > (double)srv_lock_wait_timeout) {
if (trx_is_interrupted(trx)
|| (srv_lock_wait_timeout < 100000000
&& wait_time > (double)srv_lock_wait_timeout)) {
trx->error_state = DB_LOCK_WAIT_TIMEOUT;
}
......@@ -2104,9 +2105,10 @@ srv_lock_timeout_thread(
wait_time = ut_difftime(ut_time(), slot->suspend_time);
if (srv_lock_wait_timeout < 100000000
&& (wait_time > (double) srv_lock_wait_timeout
|| wait_time < 0)) {
if (trx_is_interrupted(thr_get_trx(slot->thr))
|| (srv_lock_wait_timeout < 100000000
&& (wait_time > (double) srv_lock_wait_timeout
|| wait_time < 0))) {
/* Timeout exceeded or a wrap-around in system
time counter: cancel the lock request queued
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment