Hello @kedarpercona ,
I have just create track lock wait bash to monitor in background and will share more information if any.
Show engine innodb status data after the query error with Query 1 ERROR: Lock wait timeout exceeded; try restarting transaction:
| InnoDB | |
=====================================
2023-07-17 04:58:04 140360814651136 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 45 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 2052 srv_active, 0 srv_shutdown, 2680 srv_idle
srv_master_thread log flush and writes: 0
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 4310
OS WAIT ARRAY INFO: signal count 4025
RW-shared spins 0, rounds 0, OS waits 0
RW-excl spins 0, rounds 0, OS waits 0
RW-sx spins 0, rounds 0, OS waits 0
Spin rounds per wait: 0.00 RW-shared, 0.00 RW-excl, 0.00 RW-sx
------------
TRANSACTIONS
------------
Trx id counter 161756626
Purge done for trx's n:o < 161749871 undo n:o < 0 state: running but idle
History list length 1432
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421864460602888, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460609672, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460602040, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460619848, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460619000, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460618152, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460624088, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460623240, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460614760, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460612216, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460621544, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460617304, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460613912, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460611368, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460610520, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460607976, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460613064, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460607128, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460608824, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460605432, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460601192, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460603736, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460604584, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460606280, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460599496, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460597800, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 421864460596952, not started
0 lock struct(s), heap size 1128, 0 row lock(s)
---TRANSACTION 161756624, ACTIVE 4 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 1128, 1 row lock(s)
MySQL thread id 55965, OS thread handle 140360691758848, query id 5043741 localhost 127.0.0.1 root updating
update `customers` set `points` = '71', `points_earned` = '10000000000470', `shopify_customers`.`updated_at` = '2023-07-14 10:03:17' where `id` = 26209133
------- TRX HAS BEEN WAITING 4 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 424 page no 194755 n bits 152 index PRIMARY of table `loyalty`.`customers` trx id 161756624 lock_mode X locks rec but not gap waiting
Record lock, heap no 63 PHYSICAL RECORD: n_fields 17; compact format; info bits 0
0: len 8; hex 00000000018feb6d; asc m;;
1: len 6; hex 000009a41b75; asc u;;
2: len 7; hex 02000005802873; asc (s;;
3: len 13; hex 36373530333636393235303837; asc 6750366925087;;
4: len 8; hex 0000000000004240; asc B@;;
5: len 30; hex 626f6e5f4c41686831553039695830507739614a3837764462426c42455a; asc bon_LAhh1U09iX0Pw9aJ87vDbBlBEZ; (total 48 bytes);
6: len 8; hex 800000000000005a; asc Z;;
7: len 8; hex 800009184e72a1ea; asc Nr ;;
8: len 7; hex 656e61626c6564; asc enabled;;
9: len 3; hex 8f64a3; asc d ;;
10: len 8; hex 577a705846493747; asc WzpXFI7G;;
11: SQL NULL;
12: len 1; hex 81; asc ;;
13: len 4; hex 63d07a1f; asc c z ;;
14: len 4; hex 64b4bced; asc d ;;
15: len 28; hex 626f6e5f4751517a5a49686e326238597968306a2f79377555413d3d; asc bon_GQQzZIhn2b8Yyh0j/y7uUA==;;
16: len 28; hex 626f6e5f2b4675744e534274342f6c34576f44625050563149673d3d; asc bon_+FutNSBt4/l4WoDbPPV1Ig==;;
------------------
---TRANSACTION 161756608, ACTIVE 56 sec
1 lock struct(s), heap size 1128, 0 row lock(s), undo log entries 1
MySQL thread id 63540, OS thread handle 140354002941696, query id 5016724 10.136.244.65 loyalty
Trx read view will not see trx with id >= 161756577, sees < 161749877
---TRANSACTION 161749877, ACTIVE 3478 sec
201 lock struct(s), heap size 24696, 423 row lock(s), undo log entries 684
MySQL thread id 17630, OS thread handle 140367990978304, query id 1444856 10.136.244.66 loyalty
Trx read view will not see trx with id >= 161749869, sees < 161749869
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests ((null))
I/O thread 1 state: waiting for completed aio requests (insert buffer thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:
Pending flushes (fsync) log: 0; buffer pool: 0
462014 OS file reads, 362430 OS file writes, 53674 OS fsyncs
1.09 reads/s, 16384 avg bytes/read, 7.16 writes/s, 6.32 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 3093, seg size 3095, 1069 merges
merged operations:
insert 1788, delete mark 11, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 6375037, node heap has 701 buffer(s)
Hash table size 6375037, node heap has 12 buffer(s)
Hash table size 6375037, node heap has 8081 buffer(s)
Hash table size 6375037, node heap has 2899 buffer(s)
Hash table size 6375037, node heap has 32 buffer(s)
Hash table size 6375037, node heap has 96 buffer(s)
Hash table size 6375037, node heap has 261 buffer(s)
Hash table size 6375037, node heap has 1892 buffer(s)
5434.50 hash searches/s, 796.27 non-hash searches/s
---
LOG
---
Log sequence number 137236257890
Log buffer assigned up to 137236257890
Log buffer completed up to 137236257890
Log written up to 137236257890
Log flushed up to 137236257890
Added dirty pages up to 137236257890
Pages flushed up to 137236257469
Last checkpoint at 137236257469
Log minimum file id is 3209
Log maximum file id is 3211
Modified age no less than 137236257890
Checkpoint age 421
Max checkpoint age 87391744
25544 log i/o's done, 2.18 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 0
Dictionary memory allocated 1054559
Buffer pool size 1572672
Buffer pool size, bytes 25766658048
Free buffers 986716
Database pages 571981
Old database pages 211149
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 227685, not young 3580178
0.35 youngs/s, 1.11 non-youngs/s
Pages read 461881, created 110965, written 322146
1.09 reads/s, 0.00 creates/s, 2.95 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 571981, unzip_LRU len: 0
I/O sum[1648]:cur[8], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 121348
Database pages 73490
Old database pages 27108
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 56111, not young 1088562
0.09 youngs/s, 0.18 non-youngs/s
Pages read 59787, created 13895, written 41015
0.04 reads/s, 0.00 creates/s, 0.33 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 73490, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 126717
Database pages 68123
Old database pages 25127
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 49959, not young 887349
0.11 youngs/s, 0.33 non-youngs/s
Pages read 56245, created 12001, written 35460
0.07 reads/s, 0.00 creates/s, 0.11 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 68123, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 123102
Database pages 71724
Old database pages 26467
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 62796, not young 964619
0.11 youngs/s, 0.60 non-youngs/s
Pages read 56367, created 15549, written 42521
0.51 reads/s, 0.00 creates/s, 0.44 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 71724, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 125308
Database pages 69525
Old database pages 25644
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 58796, not young 639648
0.04 youngs/s, 0.00 non-youngs/s
Pages read 55315, created 14568, written 45431
0.02 reads/s, 0.00 creates/s, 0.69 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 69525, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 123308
Database pages 71528
Old database pages 26423
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 6, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 57064, created 14464, written 40665
0.13 reads/s, 0.00 creates/s, 0.29 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 71528, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 122716
Database pages 72125
Old database pages 26644
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 5, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 58464, created 13661, written 38753
0.09 reads/s, 0.00 creates/s, 0.27 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 72125, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 122052
Database pages 72787
Old database pages 26888
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 8, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 60298, created 12489, written 37825
0.18 reads/s, 0.00 creates/s, 0.27 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 72787, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size 196584
Buffer pool size, bytes 3220832256
Free buffers 122165
Database pages 72679
Old database pages 26848
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 4, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 58341, created 14338, written 40476
0.04 reads/s, 0.00 creates/s, 0.55 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 72679, unzip_LRU len: 0
I/O sum[206]:cur[1], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
2 read views open inside InnoDB
3 RW transactions active inside InnoDB
---OLDEST VIEW---
Read view low limit trx n:o 161749869
Trx read view will not see trx with id >= 161749869, sees < 161749869
Read view individually stored trx ids:
-----------------
Process ID=85705, Main thread ID=140360881792768 , state=sleeping
Number of rows inserted 28345211, updated 2696, deleted 542, read 142329738
0.27 inserts/s, 0.36 updates/s, 0.00 deletes/s, 6595.68 reads/s
Number of system rows inserted 8, updated 332, deleted 55, read 13013
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
Thank you,
Canh