Bug #39697 Maria: hang when failing to insert due to UNIQUE (seen in pushbuild2 too)
Submitted: 27 Sep 2008 16:10 Modified: 9 Jan 2009 15:26
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Maria storage engine Severity:S3 (Non-critical)
Version:5.1-maria OS:Linux
Assigned to: Guilhem Bichot CPU Architecture:Any

[27 Sep 2008 16:10] Guilhem Bichot
Description:
This does not affect 6.0-maria, only mysql-maria.

-- source include/have_maria.inc

create table t (a int, unique(a)) engine=maria;
insert into t values(1);
--error 1062
insert into t values(2),(2);

connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
insert into t values(3);

Leads to a hang of the thread inserting 3. It's blocked on getting a rwlock in maria_write():
166           if (local_lock_tree)
(gdb)
168             rw_wrlock(&keyinfo->root_lock); 
This rwlock is probably not unlocked by the failed insertion of the second "2".

How to repeat:
see how-to-repeat.
[27 Sep 2008 16:12] Guilhem Bichot
I sent to Serg some info; the problem seems to be maria_write() which does not unlock the rwlock (after the deadlock detector patch).
[9 Oct 2008 20:18] Guilhem Bichot
patch at http://lists.mysql.com/maria/201.
Pushed in 5.1-maria.
Serg quickly approved a short version of the patch on IRC, may be interested in looking at the full version.
[26 Oct 2008 22:20] Bugs System
Pushed into 6.0.8-alpha  (revid:guilhem@mysql.com-20081009200354-9vy3vvcxtd6x7rz0) (version source revid:guilhem@mysql.com-20081020191322-i0e65e3k8044kkce) (pib:5)
[9 Jan 2009 15:26] MC Brown
Added a note to the 6.0.8 changelog: 

Performing an INSERT on Maria table with a UNIQUE column, MySQL could deadlock.