I tested stock v5.6 with a large table where "id" column has data from 1 to 1M, and "a" column has data from 1M to 1, and two sessions scanning and locking the rows from two directions. I tried it again and captured the innodb output:
Server version: 5.6.19 MySQL Community Server (GPL)
------------------------
LATEST DETECTED DEADLOCK
------------------------
2014-06-13 16:27:01 7f191c1f3700
*** (1) TRANSACTION:
TRANSACTION 20495, ACTIVE 12 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 2100 lock struct(s), heap size 357928, 1196493 row lock(s)
MySQL thread id 3, OS thread handle 0x7f191c2b6700, query id 51 localhost root Sending data
select a from t1 order by a for update
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 64 page no 1295 n bits 576 index `PRIMARY` of table `test`.`t1` trx id 20495 lock_mode X locks rec but not gap waiting
Record lock, heap no 349 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 8009dffd; asc ;;
1: len 6; hex 00000000500e; asc P ;;
2: len 7; hex 0a000008f110d9; asc ;;
3: len 4; hex 80056243; asc bC;;
4: len 3; hex 666f6f; asc foo;;
*** (2) TRANSACTION:
TRANSACTION 20494, ACTIVE 13 sec fetching rows
mysql tables in use 1, locked 1
1632 lock struct(s), heap size 226856, 452209 row lock(s), undo log entries 450579
MySQL thread id 7, OS thread handle 0x7f191c1f3700, query id 50 localhost root updating
update t1 set b = "foo"
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 64 page no 1295 n bits 576 index `PRIMARY` of table `test`.`t1` trx id 20494 lock_mode X
Record lock, heap no 349 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 8009dffd; asc ;;
1: len 6; hex 00000000500e; asc P ;;
2: len 7; hex 0a000008f110d9; asc ;;
3: len 4; hex 80056243; asc bC;;
4: len 3; hex 666f6f; asc foo;;
.....
......
.........
Laurynas,
I couldn't use the above testcase on stock v5.6 due to http:// bugs.mysql. com/bug. php?id= 72748.
I tested stock v5.6 with a large table where "id" column has data from 1 to 1M, and "a" column has data from 1M to 1, and two sessions scanning and locking the rows from two directions. I tried it again and captured the innodb output:
Server version: 5.6.19 MySQL Community Server (GPL)
------- ------- ------- --- ------- ------- ---
LATEST DETECTED DEADLOCK
-------
2014-06-13 16:27:01 7f191c1f3700
*** (1) TRANSACTION:
TRANSACTION 20495, ACTIVE 12 sec fetching rows
mysql tables in use 1, locked 1
LOCK WAIT 2100 lock struct(s), heap size 357928, 1196493 row lock(s)
MySQL thread id 3, OS thread handle 0x7f191c2b6700, query id 51 localhost root Sending data
select a from t1 order by a for update
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 64 page no 1295 n bits 576 index `PRIMARY` of table `test`.`t1` trx id 20495 lock_mode X locks rec but not gap waiting
Record lock, heap no 349 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 8009dffd; asc ;;
1: len 6; hex 00000000500e; asc P ;;
2: len 7; hex 0a000008f110d9; asc ;;
3: len 4; hex 80056243; asc bC;;
4: len 3; hex 666f6f; asc foo;;
*** (2) TRANSACTION:
TRANSACTION 20494, ACTIVE 13 sec fetching rows
mysql tables in use 1, locked 1
1632 lock struct(s), heap size 226856, 452209 row lock(s), undo log entries 450579
MySQL thread id 7, OS thread handle 0x7f191c1f3700, query id 50 localhost root updating
update t1 set b = "foo"
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 64 page no 1295 n bits 576 index `PRIMARY` of table `test`.`t1` trx id 20494 lock_mode X
Record lock, heap no 349 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 8009dffd; asc ;;
1: len 6; hex 00000000500e; asc P ;;
2: len 7; hex 0a000008f110d9; asc ;;
3: len 4; hex 80056243; asc bC;;
4: len 3; hex 666f6f; asc foo;;
.....
......
.........