@webivan1

Как исправить «Serialization failure: 1213 Deadlock found when trying to get lock»?

Переделывали один проект на yii1, оптимизировали запросы и другие штуки.
Выкатили и не можем не нарадоваться, пока не стали приходить письма что коллеги видят ошибки 500 на сайте...
Я не пойму что происходит, захожу на страницу и там ничего нет, но в один "прекрасный день" я наткнулся на эту ошибку, которая почему-то не всегда появляется, а очень редко:

Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

Админ нам помогать не хочет, говорит это все у вас, сами разруливайте, что понаписали.
Единственное выполнил из под рута команду: SHOW ENGINE INNODB STATUS.
Ответ такой был:
| InnoDB |      | 
=====================================
2017-01-20 18:17:30 7ff0a7ec8700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 27 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 3 srv_active, 0 srv_shutdown, 450 srv_idle
srv_master_thread log flush and writes: 453
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 1281
OS WAIT ARRAY INFO: signal count 1333
Mutex spin waits 19051, rounds 2470, OS waits 20
RW-shared spins 1497, rounds 37103, OS waits 1209
RW-excl spins 1108, rounds 3066, OS waits 45
Spin rounds per wait: 0.13 mutex, 24.78 RW-shared, 2.77 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 86502654
Purge done for trx's n:o < 86501657 undo n:o < 0 state: running but idle
History list length 1141
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 30, OS thread handle 0x7ff0a7ec8700, query id 502 localhost root init
SHOW ENGINE INNODB STATUS
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log 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)
I/O thread 9 state: waiting for completed aio requests (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
13531 OS file reads, 5 OS file writes, 5 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 7526, seg size 7528, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 1051752548910
Log flushed up to   1051752548910
Pages flushed up to 1051752548910
Last checkpoint at  1051752548910
Max checkpoint age    106117817
Checkpoint age target 102801636
Modified age          0
Checkpoint age        0
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 558891008; in additional pool allocated 0
Total memory allocated by read views 88
Internal hash tables (constant factor + variable factor)
    Adaptive hash index 10215120        (8851048 + 1364072)
    Page hash           553976 (buffer pool 0 only)
    Dictionary cache    2685512         (2214224 + 471288)
    File system         2913952         (812272 + 2101680)
    Lock system         1329536         (1329176 + 360)
    Recovery system     0       (0 + 0)
Dictionary memory allocated 471288
Buffer pool size        32767
Buffer pool size, bytes 536854528
Free buffers            19196
Database pages          13488
Old database pages      4998
Modified db pages       0
Percent of dirty pages(LRU & free pages): 0.000
Max dirty pages percent: 75.000
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 13488, created 0, written 1
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: 13488, 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
0 read views open inside InnoDB
0 RW transactions active inside InnoDB
0 RO transactions active inside InnoDB
0 out of 1000 descriptors used
Main thread process no. 14168, id 140670605977344, state: sleeping
Number of rows inserted 0, updated 0, deleted 0, read 1355759
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
Number of system 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
============================

Что из этого я должен понять? Помогите разобраться что и как, непонятно же какой запрос глючит или это сама база прикалывается.
  • Вопрос задан
  • 1012 просмотров
Пригласить эксперта
Ответы на вопрос 2
Rsa97
@Rsa97
Для правильного вопроса надо знать половину ответа
Что бы такое видеть сразу запросы к БД в try/catch с логированием делайте сразу
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы