InnoDB, 4.1.20, INS/DEL/TX -- Why table-level locking?

InnoDB, 4.1.20, INS/DEL/TX -- Why table-level locking?

am 07.07.2006 15:43:41 von shakah

Just started investigating InnoDB after having used MyISAM tables in
the 4.0.12 version, almost immediately ran into a locking issue with
INSERTs, DELETEs, and transactions.

Given the following table:
CREATE TABLE test1 (
f1 varchar(32) default NULL
)

and a steady stream of INSERTs from a command-line shell:
jc@soyuz:~$ while true; do /usr/local/mysql/bin/mysql -S
/tmp/mysql-4.1.sock -u tester -D jlb -A -N -s -q -e "INSERT INTO test1
VALUES('`date`')"; done

why is it that the following session blocks the INSERTs due to locking?
jc@soyuz:~/tmp$ /usr/local/mysql/bin/mysql -S /tmp/mysql-4.1.sock -u
tester -p -D jlb

mysql> BEGIN ;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM test1 WHERE f1 LIKE 'asdf;ljkas;fjd;adsfads%' ;
Query OK, 0 rows affected (0.05 sec)

mysql> show innodb status \G
*************************** 1. row ***************************
Status:
=====================================
060707 9:34:36 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 38 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 251, signal count 249
Mutex spin waits 343, rounds 2273, OS waits 72
RW-shared spins 156, OS waits 77; RW-excl spins 100, OS waits 95
------------
TRANSACTIONS
------------
Trx id counter 0 10526
Purge done for trx's n:o < 0 7801 undo n:o < 0 0
History list length 0
Total number of lock structs in row lock hash table 11
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 10525, ACTIVE 7 sec, OS thread id 15 inserting
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 320
MySQL thread id 9256, query id 18746 localhost root update
INSERT INTO test1 VALUES('Fri Jul 7 09:34:29 EDT 2006')
------- TRX HAS BEEN WAITING 7 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 1 page no 13 n bits 336 index `GEN_CLUST_INDEX`
of table `jlb/test1` trx id 0 10525 lock_mode X in
sert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; 1-byte offs TRUE;
info bits 0
0: len 9; hex 73757072656d756d00; asc supremum ;;

------------------
---TRANSACTION 0 10524, ACTIVE 7 sec, OS thread id 13
11 lock struct(s), heap size 1024
MySQL thread id 9150, query id 18747 localhost root
show innodb status
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (write thread)
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
26 OS file reads, 9848 OS file writes, 9604 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 18.76 writes/s, 18.39 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2, is empty
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 415141, used cells 1, node heap has 1 buffer(s)
17.66 hash searches/s, 0.34 non-hash searches/s
---
LOG
---
Log sequence number 0 1673501
Log flushed up to 0 1673501
Last checkpoint at 0 1673501
0 pending log writes, 0 pending chkp writes
9283 log i/o's done, 17.97 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 141111128; in additional pool allocated 1403776
Buffer pool size 6400
Free buffers 6321
Database pages 78
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 64, created 14, written 642
0.00 reads/s, 0.05 creates/s, 0.82 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
Main thread id 10, state: waiting for server activity
Number of rows inserted 9168, updated 1062, deleted 8865, read 66649
17.87 inserts/s, 0.00 updates/s, 0.00 deletes/s, 71.42 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.03 sec)

mysql>