SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transactionソリューション(一)
4105 ワード
"SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transactionThe SQL being executed was: UPDATE `user` SET `updated_at`=1584495239, `online_ping_time`=1584495239 WHERE `id`=100604575","trace"
MySQLでは、このような遅延の異常が報告されることがあります.
一、問題分析
ネット上の関連問題の検索を経て、このような問題を解決する分析構想をまとめた.
まず、SQLの実行時間が長すぎて、データベース設定のデフォルトの遅延時間を超えています.分析した場合、確かに一部のトランザクションの遅延が大きすぎるためです.分析の考え方と手順は次のとおりです.
ステップ1:影響を表示するtableステップ2:すべての追加ロックの種類とその他の反発情報を取得する
分析データ:
解決策参照(二)
MySQLでは、このような遅延の異常が報告されることがあります.
一、問題分析
ネット上の関連問題の検索を経て、このような問題を解決する分析構想をまとめた.
まず、SQLの実行時間が長すぎて、データベース設定のデフォルトの遅延時間を超えています.分析した場合、確かに一部のトランザクションの遅延が大きすぎるためです.分析の考え方と手順は次のとおりです.
ステップ1:影響を表示するtableステップ2:すべての追加ロックの種類とその他の反発情報を取得する
分析データ:
mysql> show engine innodb status\G
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
200318 11:44:53 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 3 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 1 1_second, 1 sleeps, 0 10_second, 1 background, 1 flush
srv_master_thread log flush and writes: 1
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 2, signal count 2
Mutex spin waits 1, rounds 1, OS waits 0
RW-shared spins 2, rounds 60, OS waits 2
RW-excl spins 0, rounds 0, OS waits 0
Spin rounds per wait: 1.00 mutex, 30.00 RW-shared, 0.00 RW-excl
------------
TRANSACTIONS
------------
Trx id counter B00
Purge done for trx's n:o < 94D undo n:o < 0
History list length 156
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 2, OS thread handle 0x2d28, query id 3 localhost 127.0.0.1 root
show engine innodb status
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (read thread)
I/O thread 4 state: wait Windows aio (read thread)
I/O thread 5 state: wait Windows aio (read thread)
I/O thread 6 state: wait Windows aio (write thread)
I/O thread 7 state: wait Windows aio (write thread)
I/O thread 8 state: wait Windows aio (write thread)
I/O thread 9 state: wait Windows aio (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
469 OS file reads, 3 OS file writes, 3 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 195193, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 2172550
Log flushed up to 2172550
Last checkpoint at 2172550
0 pending log writes, 0 pending chkp writes
8 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 49938432; in additional pool allocated 0
Dictionary memory allocated 20114
Buffer pool size 3008
Free buffers 2678
Database pages 330
Old database pages 0
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 0, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 330, created 0, written 0
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 330, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 28360, state: waiting for server activity
Number of rows inserted 0, updated 0, deleted 0, read 0
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
1 row in set (0.00 sec)
mysql>
解決策参照(二)