HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How can I find who holds the lock based on the hex-dumped?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
canthehowwhodumpedhexbasedfindholdslock

Problem

I've been reading the Diagnosing MySQL InnoDB Locks article. Karl E. Jørgensen writes on 2008 so I'm consfusing it is in effect.

I would like to supply a snippet of the SHOW ENGINE INNODB STATUS:

---TRANSACTION 20532F16, ACTIVE 386 sec starting index read
mysql tables in use 6, locked 6
LOCK WAIT 2 lock struct(s), heap size 1248, 1 row lock(s)
MySQL thread id 96238, query id 81681916 192.168.6.31 thanhnt updating
DELETE FROM `v3_zone_date`  
    WHERE `dt` = NAME_CONST('_currDate',_latin1'2012-03-02' COLLATE 'latin1_swedish_ci')
------- TRX HAS BEEN WAITING 8 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 482988 page no 6 n bits 360 index `GEN_CLUST_INDEX` of table `reportingdb`.`v3_zone_date` /* Partition `pcurrent_201232` */ trx id 20532F16 lock_mode X waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 13; compact format; info bits 0
 0: len 6; hex 000237440e77; asc   7D w;;
 1: len 6; hex 0000204f2acb; asc    O* ;;
 2: len 7; hex e6000480120110; asc        ;;
 3: len 3; hex 8f5340; asc  S@;;
 4: len 2; hex 83d4; asc   ;;
 5: len 3; hex 814f42; asc  OB;;
 6: len 3; hex 000000; asc    ;;
 7: len 3; hex 000000; asc    ;;
 8: len 3; hex 800000; asc    ;;
 9: len 3; hex 000001; asc    ;;
 10: len 3; hex 000000; asc    ;;
 11: len 3; hex 8fb862; asc   b;;
 12: len 2; hex 0000; asc   ;;

------------------
---TRANSACTION 20532EE8, ACTIVE 437 sec fetching rows, thread declared inside InnoDB 236
mysql tables in use 22, locked 22
24944 lock struct(s), heap size 3586488, 11457529 row lock(s)
MySQL thread id 97447, query id 81504647 event_scheduler Copying to tmp table


The query is cut off apart so I get it from the SHOW FULL PROCESSLIST output:

``
18. row
Id: 97447
User: thanhnt
Host: 192.168.6.31
db: reportingdb
Command: Connect
Time: 423
State: Copying to tmp table
Info: UPDATE
selfserving_banner_zone A,( SELECT B.bannerid,C.zoneid,ROUND(SUM(C.realclick`)*

Solution

This is really easy now. Don't use SHOW ENGINE INNODB STATUS, use information_schema.innodb_locks. Here's an example I wrote a blog post on with foreign keys:

http://www.mysqlperformanceblog.com/2010/09/20/instrumentation-and-the-cost-of-foreign-keys/

Context

StackExchange Database Administrators Q#14257, answer score: 5

Revisions (0)

No revisions yet.