Commit 7cb4a1c6 authored by Michael Widenius's avatar Michael Widenius

Fixed MDEV-7314: Deadlock when doing insert-select with Aria


mysql-test/suite/maria/insert_select.result:
  Added test case
mysql-test/suite/maria/insert_select.test:
  Added test case
mysys/thr_lock.c:
  Ensure we don't allow concurrent_insert when a read_no_write lock is in use
parent 32be7dff
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
#
# MDEV-7314
# Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are
# hitting deadlocks on Aria tables using ROW_FORMAT=PAGE
#
create table t1 (pk int primary key) engine=Aria;
insert into t1 values (1);
insert into t1 select sleep(2)+1 from t1;
insert into t1 select 2 from t1;
select * from t1;
pk
1
2
drop table t1;
-- source include/have_maria.inc
--source include/have_binlog_format_statement.inc
drop table if exists t1;
--echo #
--echo # MDEV-7314
--echo # Concurrent "INSERT INTO table SELECT MAX(id)+1 FROM table" are
--echo # hitting deadlocks on Aria tables using ROW_FORMAT=PAGE
--echo #
create table t1 (pk int primary key) engine=Aria;
insert into t1 values (1);
send insert into t1 select sleep(2)+1 from t1;
--connect (con1,localhost,root,,)
--error 0,1062
insert into t1 select 2 from t1;
--connection default
--error 0,1062
--reap
select * from t1;
drop table t1;
......@@ -833,7 +833,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
if (((lock_type == TL_WRITE_ALLOW_WRITE ||
(lock_type == TL_WRITE_CONCURRENT_INSERT &&
lock->allow_multiple_concurrent_insert)) &&
lock->allow_multiple_concurrent_insert &&
!lock->read_no_write_count)) &&
! lock->write_wait.data &&
lock->write.data->type == lock_type) ||
has_old_lock(lock->write.data, data->owner))
......
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