MariaDB 有时很长的请求不会出现在慢速日志中
MariaDB sometime very long request does not appears in slow logs
我正在使用 MariaDB 10.4.12-MariaDB-1:10.4.12+maria~stretch-log
innodb 在 debian 的延伸。
我面临一个非常慢的问题 insert/update/delete 查询
用了 多 超过 10 秒,但没有 出现在慢速查询日志中。
这些长时间 运行ning 请求仅在服务器接收到
像往常一样有更多请求(大约 20/s)。
记录慢速请求的变量如下:
MariaDB [(none)]> show variables like 'long_query_time';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.001 sec)
例如下面的更新语句很简单,使用了table的主键:
delete from WEDMATTP Where AttRef like 'EDM-%-FOLDER' and DocId in( 1638486)
实际上没有 AttRef like 'EDM-%-FOLDER'
的记录,只有 DocId in( 1638486)
的记录
EXPLAIN 命令说:
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | WEDMATTP | range | PRIMARY,WEDMATTP_DocNum | PRIMARY | 70 | NULL | 1 | Using where |
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
1 row in set (0.001 sec)
table 创建如下:
MariaDB [abngmadbprod]> show create table wedmattp\G
*************************** 1. row ***************************
Table: wedmattp
Create Table: CREATE TABLE "wedmattp" (
"DocId" int(11) NOT NULL,
"AttRef" varchar(64) NOT NULL,
"AttDate" varchar(14) NOT NULL,
"AttUser" varchar(20) DEFAULT NULL,
"AttMode" varchar(1) DEFAULT NULL,
"UsrId" int(11) DEFAULT NULL,
"AttEndDate" varchar(14) DEFAULT NULL,
PRIMARY KEY ("DocId","AttRef"),
KEY "WEDMATTP_DocNum" ("AttRef"),
KEY "WEDMATTP_AttDate" ("AttDate"),
KEY "WEDMATTP_Usr" ("UsrId"),
KEY "WEDMATTP_AttUser" ("AttUser"),
CONSTRAINT "FK_DocAtt" FOREIGN KEY ("DocId") REFERENCES "wedmdocp" ("DocId")
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.483 sec)
但是当我在这个请求 运行ning 时查看进程时:
Id User Host db Command Time State Info Progress
1 system user NULL Daemon NULL InnoDB purge coordinator NULL 0.000
2 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
3 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
4 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
5 system user NULL Daemon NULL InnoDB shutdown handler NULL 0.000
13 repl srvdatae.antemeta.lan:46504 NULL Binlog Dump 105901 Master has sent all binlog to slave; waiting for binlog to be updated NULL 0.000
325584 wyxuser_g_abn srvappd:39384 abnwyxdbprod Sleep 30 NULL 0.000
325589 wyxuser_g_abn srvappe:57448 abnwyxdbprod Sleep 30 NULL 0.000
325663 wyxuser_ph_edm srvappe:57526 abnwyxdbprod Query 14 Updating delete from WEDMATTP Where AttRef like 'EDM-%-FOLDER' and DocId in( 1638486) 0.000
325673 wyxuser_ph_edm srvappd:39468 abnwyxdbprod Query 14 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1638487, 'WYX-10701/GLI-448398-DAT', '20211129081046', '-NESTOR-BURMA-', 'P') 0.000
326176 wyxuser_g_abn srvappe:58170 abnwyxdbprod Sleep 8 NULL 0.000
326199 wyxuser_g_abn srvappe:58208 abnwyxdbprod Sleep 7 NULL 0.000
326290 wyxuser_ph_edm srvappe:58302 abnwyxdbprod Query 3 Waiting for table level lock insert into WEDMITMP(StkId,ItmId,ItmDate,ItmOrder) values( 7503,1638488,\n'20211129081058', 0 ) 0.000
326308 wyxuser_ph_edm srvappe:58330 abnwyxdbprod Query 3 Waiting for table level lock insert into WEDMITMP(StkId,ItmId,ItmDate,ItmOrder) values( 7503,1638489,\n'20211129081058', 0 ) 0.000
326441 wyxuser_g_oauth srvappd:40056 oauth2prod Sleep 0 NULL 0.000
326457 wyxuser_g_admin srvappd:40088 adminwyxdbprod Sleep 0 NULL 0.000
326458 root localhost NULL Query 0 Init show full processlist 0.000
当我查看进程时,请求 运行ning 持续了 14 秒,但它没有出现在慢速日志中。
它通常 运行 非常快但不是那个时候。而且服务器似乎负载不是很大(只有 4 个请求 运行ning)。
其他一些 运行 快速(<1 秒)的常见请求在这种情况下可能需要超过 60 秒。
我怀疑是死锁,但在上面 show processlist
的情况下,如果删除请求当前处于“正在更新”状态,是否有可能出现死锁?
很抱歉回复得太晚了。我在等待错误再次发生,以便能够提供 innodb 状态。
table wedmattp select count(*) from wedmattp
的维度超过 1700000 行。
对于这个特定的 Docid 值,我无法判断 SELECT COUNT(*) FROM wedmattp WHERE DocId in( 1638486)
的结果,但 99% 的 Docid 都少于 7 行。
我们所有的客户端连接都明确地使用 latin1。
这是我在发生错误(长请求)时获得的带有 innodb 状态的新日志。首先是 show processlist
=== mercredi 1 décembre 2021, 07:03:01 (UTC+0100)
Id User Host db Command Time State Info Progress
1 system user NULL Daemon NULL InnoDB purge coordinator NULL 0.000
2 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
3 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
4 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
5 system user NULL Daemon NULL InnoDB shutdown handler NULL 0.000
13 repl srvdatae.antemeta.lan:46504 NULL Binlog Dump 271021 Master has sent all binlog to slave; waiting for binlog to be updated NULL 0.000
1714646 wyxuser_g_abn srvappe:42218 abnwyxdbprod Sleep 33 NULL 0.000
1714673 wyxuser_g_abn srvappe:42252 abnwyxdbprod Sleep 31 NULL 0.000
1714677 wyxuser_ph_edm srvappe:42260 abnwyxdbprod Sleep 30 NULL 0.000
1714682 wyxuser_g_abn srvappe:42270 abnwyxdbprod Sleep 30 NULL 0.000
1714685 wyxuser_ph_edm srvappe:42276 abnwyxdbprod Query 29 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648830, 'WYX-16665/GLI-845449-DAT', '20211201060231', '-NESTOR-BURMA-', 'P') 0.000
1714695 wyxuser_ph_edm srvappe:42288 abnwyxdbprod Query 29 Update INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648831, 'WYX-3315/251985-CHR', '20211201060231', '-NESTOR-BURMA-', 'P') 0.000
1714702 wyxuser_g_abn srvappe:42302 abnwyxdbprod Sleep 26 NULL 0.000
1714711 wyxuser_ph_edm srvappe:42320 abnwyxdbprod Query 25 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648832, 'WYX-10012/FAC-72539-DAT', '20211201060236', 'DR7FFC49', 'P') 0.000
1714784 root localhost NULL Query 0 Init show full processlist 0.000
mariadb 进程的 ps
(我在 VM 上有 2 个 MariaDB 服务器)。
PID TID PRI PSR %CPU STAT COMMAND
33006 33006 19 0 4.7 Ssl /usr/sbin/mysqld
33176 33176 19 0 0.9 Ssl /usr/sbin/mysqld --defaults-file=/etc/mysql/my.prep.cnf
然后show engine innodb status
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2021-12-01 07:03:01 0x7f0f045ba700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 60 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 64402 srv_active, 0 srv_shutdown, 206431 srv_idle
srv_master_thread log flush and writes: 270771
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 2448713
OS WAIT ARRAY INFO: signal count 1451239
RW-shared spins 0, rounds 93744, OS waits 30846
RW-excl spins 0, rounds 71000, OS waits 1448
RW-sx spins 640, rounds 15776, OS waits 386
Spin rounds per wait: 93744.00 RW-shared, 71000.00 RW-excl, 24.65 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2021-11-29 17:23:12 0x7f10a063b700 Transaction:
TRANSACTION 48868328, ACTIVE 1 sec updating or deleting
mysql tables in use 2, locked 2
36 lock struct(s), heap size 3520, 24 row lock(s), undo log entries 7
MySQL thread id 712238, OS thread handle 139709387093760, query id 5527984 srvappe 10.100.15.22 wyxuser_g_abn Updating
Delete from exercice where
AbnId=13118
and ExrId=712495
and AbnId = 13118
Foreign key constraint fails for table "abnwyxdbprod"."documentcomptable":
,
CONSTRAINT "FK_DCTEXR" FOREIGN KEY ("AbnId", "ExrId") REFERENCES "exercice" ("ABNID", "EXRID")
Trying to delete or update in parent table, in index PRIMARY tuple:
DATA TUPLE: 19 fields;
0: len 8; hex 800000000000333e; asc 3>;;
1: len 4; hex 800adf2f; asc /;;
2: len 6; hex 000002e9abe8; asc ;;
3: len 7; hex 7300001d6c2404; asc s l$ ;;
4: len 4; hex 800934d9; asc 4 ;;
5: len 3; hex 8fcb1f; asc ;;
6: SQL NULL;
7: SQL NULL;
8: SQL NULL;
9: SQL NULL;
10: SQL NULL;
11: SQL NULL;
12: SQL NULL;
13: len 3; hex 8fc921; asc !;;
14: len 5; hex 99aa84cbe4; asc ;;
15: SQL NULL;
16: len 8; hex 8000000000000ff0; asc ;;
17: SQL NULL;
18: SQL NULL;
But in child table "abnwyxdbprod"."documentcomptable", in index FK_DCTEXR, there is a record:
PHYSICAL RECORD: n_fields 3; compact format; info bits 0
0: len 8; hex 800000000000333e; asc 3>;;
1: len 4; hex 800adf2f; asc /;;
2: len 4; hex 80008c0c; asc ;;
------------
TRANSACTIONS
------------
Trx id counter 49129983
Purge done for trx's n:o < 49129967 undo n:o < 0 state: running but idle
History list length 6
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421184365078104, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365073848, not started
mysql tables in use 2, locked 2
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365069592, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 49129968, ACTIVE 30 sec inserting
mysql tables in use 2, locked 2
LOCK WAIT 4 lock struct(s), heap size 1136, 2 row lock(s)
MySQL thread id 1714695, OS thread handle 139702474045184, query id 13382588 srvappe 10.100.15.22 wyxuser_ph_edm Update
INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode )
VALUES (1648831, 'WYX-3315/251985-CHR', '20211201060231', '-NESTOR-BURMA-', 'P')
------- TRX HAS BEEN WAITING 30 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2184 page no 35846 n bits 88 index PRIMARY of table "abnwyxdbprod"."wedmattp" trx id 49129968 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;;
------------------
---TRANSACTION 49129964, ACTIVE 30 sec
mysql tables in use 2, locked 2
9 lock struct(s), heap size 1136, 4 row lock(s), undo log entries 5
MySQL thread id 1714685, OS thread handle 139702475888384, query id 13382604 srvappe 10.100.15.22 wyxuser_ph_edm Waiting for table level lock
INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode )
VALUES (1648830, 'WYX-16665/GLI-845449-DAT', '20211201060231', '-NESTOR-BURMA-', 'P')
Trx read view will not see trx with id >= 49129964, sees < 49129964
---TRANSACTION 49129965, ACTIVE 30 sec
5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 2
MySQL thread id 1714682, OS thread handle 139702634723072, query id 13382505 srvappe 10.100.15.22 wyxuser_g_abn
Trx read view will not see trx with id >= 49129964, sees < 49129964
---TRANSACTION 421184365056824, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365048312, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365044056, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365039800, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
239885 OS file reads, 1261322 OS file writes, 792802 OS fsyncs
0.03 reads/s, 16384 avg bytes/read, 23.67 writes/s, 11.38 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 2465, seg size 2467, 5023 merges
merged operations:
insert 7935, delete mark 538, delete 64
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 1593833, node heap has 5997 buffer(s)
Hash table size 1593833, node heap has 672 buffer(s)
Hash table size 1593833, node heap has 1167 buffer(s)
Hash table size 1593833, node heap has 3436 buffer(s)
Hash table size 1593833, node heap has 856 buffer(s)
Hash table size 1593833, node heap has 3387 buffer(s)
Hash table size 1593833, node heap has 603 buffer(s)
Hash table size 1593833, node heap has 1399 buffer(s)
13150.30 hash searches/s, 639.77 non-hash searches/s
---
LOG
---
Log sequence number 35793553330
Log flushed up to 35793553330
Pages flushed up to 35793553330
Last checkpoint at 35793553321
0 pending log flushes, 0 pending chkp writes
323373 log i/o's done, 4.05 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 6476005376
Dictionary memory allocated 729456
Buffer pool size 384720
Free buffers 114421
Database pages 252782
Old database pages 93407
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 983, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 239608, created 13174, written 794983
0.03 reads/s, 0.03 creates/s, 18.28 writes/s
Buffer pool hit rate 999 / 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: 252782, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 48090
Free buffers 14073
Database pages 31811
Old database pages 11759
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 112, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30092, created 1719, written 131533
0.02 reads/s, 0.02 creates/s, 4.47 writes/s
Buffer pool hit rate 999 / 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: 31811, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 48090
Free buffers 14285
Database pages 31624
Old database pages 11692
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 111, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29985, created 1639, written 95837
0.00 reads/s, 0.00 creates/s, 0.93 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: 31624, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size 48090
Free buffers 14213
Database pages 31657
Old database pages 11705
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 119, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30089, created 1568, written 56444
0.00 reads/s, 0.00 creates/s, 1.60 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: 31657, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size 48090
Free buffers 15270
Database pages 30638
Old database pages 11323
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 136, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 28829, created 1809, written 172234
0.02 reads/s, 0.00 creates/s, 4.33 writes/s
Buffer pool hit rate 999 / 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: 30638, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size 48090
Free buffers 14058
Database pages 31870
Old database pages 11768
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 137, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30401, created 1469, written 111736
0.00 reads/s, 0.02 creates/s, 2.68 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: 31870, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size 48090
Free buffers 13700
Database pages 32215
Old database pages 11911
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 131, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30630, created 1585, written 91920
0.00 reads/s, 0.00 creates/s, 1.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: 32215, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size 48090
Free buffers 14818
Database pages 31074
Old database pages 11489
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 116, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29606, created 1468, written 67979
0.00 reads/s, 0.00 creates/s, 1.57 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: 31074, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size 48090
Free buffers 14004
Database pages 31893
Old database pages 11760
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 121, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29976, created 1917, written 67300
0.00 reads/s, 0.00 creates/s, 0.75 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: 31893, 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
2 read views open inside InnoDB
Process ID=33006, Main thread ID=139702735435520, state: sleeping
Number of rows inserted 296865, updated 190576, deleted 9070, read 8255654063
2.97 inserts/s, 1.15 updates/s, 0.03 deletes/s, 59423.73 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 5378
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
如果 mysqld 在查询完成之前崩溃,则该查询不会写入慢日志。这是一个不幸的事实 -- 有时 运行ning 长的查询是导致崩溃的一个因素。
如果它没有崩溃,那么我们会深入研究。
请提供SELECT COUNT(*) FROM wedmattp WHERE DocId in( 1638486)
.
并且... SHOW ENGINE=InnoDB STATUS;
在删除 and/or 之后是 运行。
导致“等待 table 级别锁定”的原因并不明显,但涉及删除操作。
连接时使用什么CHARACTER SET
连接(用于删除)?
同时,我建议将 long_query_time
降低到 1
。 (这对当前问题没有帮助,但会帮助您找到更多慢查询。)
更多
The EXPLAIN command says
是 EXPLAIN UPDATE...
还是 EXPLAIN
对等 Select?
请打开慢速日志中的解释,以便我们何时可以在那里显示内容。 (我认为它类似于 log_slow_verbosity=explain)
同时,执行 SHOW EXPLAIN
以获取有关 运行ning 查询.
的信息
我正在使用 MariaDB 10.4.12-MariaDB-1:10.4.12+maria~stretch-log innodb 在 debian 的延伸。
我面临一个非常慢的问题 insert/update/delete 查询 用了 多 超过 10 秒,但没有 出现在慢速查询日志中。
这些长时间 运行ning 请求仅在服务器接收到 像往常一样有更多请求(大约 20/s)。
记录慢速请求的变量如下:
MariaDB [(none)]> show variables like 'long_query_time';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.001 sec)
例如下面的更新语句很简单,使用了table的主键:
delete from WEDMATTP Where AttRef like 'EDM-%-FOLDER' and DocId in( 1638486)
实际上没有 AttRef like 'EDM-%-FOLDER'
的记录,只有 DocId in( 1638486)
的记录
EXPLAIN 命令说:
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | WEDMATTP | range | PRIMARY,WEDMATTP_DocNum | PRIMARY | 70 | NULL | 1 | Using where |
+------+-------------+----------+-------+-------------------------+---------+---------+------+------+-------------+
1 row in set (0.001 sec)
table 创建如下:
MariaDB [abngmadbprod]> show create table wedmattp\G
*************************** 1. row ***************************
Table: wedmattp
Create Table: CREATE TABLE "wedmattp" (
"DocId" int(11) NOT NULL,
"AttRef" varchar(64) NOT NULL,
"AttDate" varchar(14) NOT NULL,
"AttUser" varchar(20) DEFAULT NULL,
"AttMode" varchar(1) DEFAULT NULL,
"UsrId" int(11) DEFAULT NULL,
"AttEndDate" varchar(14) DEFAULT NULL,
PRIMARY KEY ("DocId","AttRef"),
KEY "WEDMATTP_DocNum" ("AttRef"),
KEY "WEDMATTP_AttDate" ("AttDate"),
KEY "WEDMATTP_Usr" ("UsrId"),
KEY "WEDMATTP_AttUser" ("AttUser"),
CONSTRAINT "FK_DocAtt" FOREIGN KEY ("DocId") REFERENCES "wedmdocp" ("DocId")
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.483 sec)
但是当我在这个请求 运行ning 时查看进程时:
Id User Host db Command Time State Info Progress
1 system user NULL Daemon NULL InnoDB purge coordinator NULL 0.000
2 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
3 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
4 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
5 system user NULL Daemon NULL InnoDB shutdown handler NULL 0.000
13 repl srvdatae.antemeta.lan:46504 NULL Binlog Dump 105901 Master has sent all binlog to slave; waiting for binlog to be updated NULL 0.000
325584 wyxuser_g_abn srvappd:39384 abnwyxdbprod Sleep 30 NULL 0.000
325589 wyxuser_g_abn srvappe:57448 abnwyxdbprod Sleep 30 NULL 0.000
325663 wyxuser_ph_edm srvappe:57526 abnwyxdbprod Query 14 Updating delete from WEDMATTP Where AttRef like 'EDM-%-FOLDER' and DocId in( 1638486) 0.000
325673 wyxuser_ph_edm srvappd:39468 abnwyxdbprod Query 14 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1638487, 'WYX-10701/GLI-448398-DAT', '20211129081046', '-NESTOR-BURMA-', 'P') 0.000
326176 wyxuser_g_abn srvappe:58170 abnwyxdbprod Sleep 8 NULL 0.000
326199 wyxuser_g_abn srvappe:58208 abnwyxdbprod Sleep 7 NULL 0.000
326290 wyxuser_ph_edm srvappe:58302 abnwyxdbprod Query 3 Waiting for table level lock insert into WEDMITMP(StkId,ItmId,ItmDate,ItmOrder) values( 7503,1638488,\n'20211129081058', 0 ) 0.000
326308 wyxuser_ph_edm srvappe:58330 abnwyxdbprod Query 3 Waiting for table level lock insert into WEDMITMP(StkId,ItmId,ItmDate,ItmOrder) values( 7503,1638489,\n'20211129081058', 0 ) 0.000
326441 wyxuser_g_oauth srvappd:40056 oauth2prod Sleep 0 NULL 0.000
326457 wyxuser_g_admin srvappd:40088 adminwyxdbprod Sleep 0 NULL 0.000
326458 root localhost NULL Query 0 Init show full processlist 0.000
当我查看进程时,请求 运行ning 持续了 14 秒,但它没有出现在慢速日志中。 它通常 运行 非常快但不是那个时候。而且服务器似乎负载不是很大(只有 4 个请求 运行ning)。
其他一些 运行 快速(<1 秒)的常见请求在这种情况下可能需要超过 60 秒。
我怀疑是死锁,但在上面 show processlist
的情况下,如果删除请求当前处于“正在更新”状态,是否有可能出现死锁?
很抱歉回复得太晚了。我在等待错误再次发生,以便能够提供 innodb 状态。
table wedmattp select count(*) from wedmattp
的维度超过 1700000 行。
对于这个特定的 Docid 值,我无法判断 SELECT COUNT(*) FROM wedmattp WHERE DocId in( 1638486)
的结果,但 99% 的 Docid 都少于 7 行。
我们所有的客户端连接都明确地使用 latin1。
这是我在发生错误(长请求)时获得的带有 innodb 状态的新日志。首先是 show processlist
=== mercredi 1 décembre 2021, 07:03:01 (UTC+0100)
Id User Host db Command Time State Info Progress
1 system user NULL Daemon NULL InnoDB purge coordinator NULL 0.000
2 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
3 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
4 system user NULL Daemon NULL InnoDB purge worker NULL 0.000
5 system user NULL Daemon NULL InnoDB shutdown handler NULL 0.000
13 repl srvdatae.antemeta.lan:46504 NULL Binlog Dump 271021 Master has sent all binlog to slave; waiting for binlog to be updated NULL 0.000
1714646 wyxuser_g_abn srvappe:42218 abnwyxdbprod Sleep 33 NULL 0.000
1714673 wyxuser_g_abn srvappe:42252 abnwyxdbprod Sleep 31 NULL 0.000
1714677 wyxuser_ph_edm srvappe:42260 abnwyxdbprod Sleep 30 NULL 0.000
1714682 wyxuser_g_abn srvappe:42270 abnwyxdbprod Sleep 30 NULL 0.000
1714685 wyxuser_ph_edm srvappe:42276 abnwyxdbprod Query 29 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648830, 'WYX-16665/GLI-845449-DAT', '20211201060231', '-NESTOR-BURMA-', 'P') 0.000
1714695 wyxuser_ph_edm srvappe:42288 abnwyxdbprod Query 29 Update INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648831, 'WYX-3315/251985-CHR', '20211201060231', '-NESTOR-BURMA-', 'P') 0.000
1714702 wyxuser_g_abn srvappe:42302 abnwyxdbprod Sleep 26 NULL 0.000
1714711 wyxuser_ph_edm srvappe:42320 abnwyxdbprod Query 25 Waiting for table level lock INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode ) \n VALUES (1648832, 'WYX-10012/FAC-72539-DAT', '20211201060236', 'DR7FFC49', 'P') 0.000
1714784 root localhost NULL Query 0 Init show full processlist 0.000
mariadb 进程的 ps
(我在 VM 上有 2 个 MariaDB 服务器)。
PID TID PRI PSR %CPU STAT COMMAND
33006 33006 19 0 4.7 Ssl /usr/sbin/mysqld
33176 33176 19 0 0.9 Ssl /usr/sbin/mysqld --defaults-file=/etc/mysql/my.prep.cnf
然后show engine innodb status
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2021-12-01 07:03:01 0x7f0f045ba700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 60 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 64402 srv_active, 0 srv_shutdown, 206431 srv_idle
srv_master_thread log flush and writes: 270771
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 2448713
OS WAIT ARRAY INFO: signal count 1451239
RW-shared spins 0, rounds 93744, OS waits 30846
RW-excl spins 0, rounds 71000, OS waits 1448
RW-sx spins 640, rounds 15776, OS waits 386
Spin rounds per wait: 93744.00 RW-shared, 71000.00 RW-excl, 24.65 RW-sx
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2021-11-29 17:23:12 0x7f10a063b700 Transaction:
TRANSACTION 48868328, ACTIVE 1 sec updating or deleting
mysql tables in use 2, locked 2
36 lock struct(s), heap size 3520, 24 row lock(s), undo log entries 7
MySQL thread id 712238, OS thread handle 139709387093760, query id 5527984 srvappe 10.100.15.22 wyxuser_g_abn Updating
Delete from exercice where
AbnId=13118
and ExrId=712495
and AbnId = 13118
Foreign key constraint fails for table "abnwyxdbprod"."documentcomptable":
,
CONSTRAINT "FK_DCTEXR" FOREIGN KEY ("AbnId", "ExrId") REFERENCES "exercice" ("ABNID", "EXRID")
Trying to delete or update in parent table, in index PRIMARY tuple:
DATA TUPLE: 19 fields;
0: len 8; hex 800000000000333e; asc 3>;;
1: len 4; hex 800adf2f; asc /;;
2: len 6; hex 000002e9abe8; asc ;;
3: len 7; hex 7300001d6c2404; asc s l$ ;;
4: len 4; hex 800934d9; asc 4 ;;
5: len 3; hex 8fcb1f; asc ;;
6: SQL NULL;
7: SQL NULL;
8: SQL NULL;
9: SQL NULL;
10: SQL NULL;
11: SQL NULL;
12: SQL NULL;
13: len 3; hex 8fc921; asc !;;
14: len 5; hex 99aa84cbe4; asc ;;
15: SQL NULL;
16: len 8; hex 8000000000000ff0; asc ;;
17: SQL NULL;
18: SQL NULL;
But in child table "abnwyxdbprod"."documentcomptable", in index FK_DCTEXR, there is a record:
PHYSICAL RECORD: n_fields 3; compact format; info bits 0
0: len 8; hex 800000000000333e; asc 3>;;
1: len 4; hex 800adf2f; asc /;;
2: len 4; hex 80008c0c; asc ;;
------------
TRANSACTIONS
------------
Trx id counter 49129983
Purge done for trx's n:o < 49129967 undo n:o < 0 state: running but idle
History list length 6
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421184365078104, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365073848, not started
mysql tables in use 2, locked 2
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365069592, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 49129968, ACTIVE 30 sec inserting
mysql tables in use 2, locked 2
LOCK WAIT 4 lock struct(s), heap size 1136, 2 row lock(s)
MySQL thread id 1714695, OS thread handle 139702474045184, query id 13382588 srvappe 10.100.15.22 wyxuser_ph_edm Update
INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode )
VALUES (1648831, 'WYX-3315/251985-CHR', '20211201060231', '-NESTOR-BURMA-', 'P')
------- TRX HAS BEEN WAITING 30 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 2184 page no 35846 n bits 88 index PRIMARY of table "abnwyxdbprod"."wedmattp" trx id 49129968 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
0: len 8; hex 73757072656d756d; asc supremum;;
------------------
---TRANSACTION 49129964, ACTIVE 30 sec
mysql tables in use 2, locked 2
9 lock struct(s), heap size 1136, 4 row lock(s), undo log entries 5
MySQL thread id 1714685, OS thread handle 139702475888384, query id 13382604 srvappe 10.100.15.22 wyxuser_ph_edm Waiting for table level lock
INSERT ignore INTO WEDMATTP (DocId, AttRef, AttDate,AttUser, AttMode )
VALUES (1648830, 'WYX-16665/GLI-845449-DAT', '20211201060231', '-NESTOR-BURMA-', 'P')
Trx read view will not see trx with id >= 49129964, sees < 49129964
---TRANSACTION 49129965, ACTIVE 30 sec
5 lock struct(s), heap size 1136, 2 row lock(s), undo log entries 2
MySQL thread id 1714682, OS thread handle 139702634723072, query id 13382505 srvappe 10.100.15.22 wyxuser_g_abn
Trx read view will not see trx with id >= 49129964, sees < 49129964
---TRANSACTION 421184365056824, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365048312, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365044056, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421184365039800, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
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] , aio writes: [0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
239885 OS file reads, 1261322 OS file writes, 792802 OS fsyncs
0.03 reads/s, 16384 avg bytes/read, 23.67 writes/s, 11.38 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 2465, seg size 2467, 5023 merges
merged operations:
insert 7935, delete mark 538, delete 64
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 1593833, node heap has 5997 buffer(s)
Hash table size 1593833, node heap has 672 buffer(s)
Hash table size 1593833, node heap has 1167 buffer(s)
Hash table size 1593833, node heap has 3436 buffer(s)
Hash table size 1593833, node heap has 856 buffer(s)
Hash table size 1593833, node heap has 3387 buffer(s)
Hash table size 1593833, node heap has 603 buffer(s)
Hash table size 1593833, node heap has 1399 buffer(s)
13150.30 hash searches/s, 639.77 non-hash searches/s
---
LOG
---
Log sequence number 35793553330
Log flushed up to 35793553330
Pages flushed up to 35793553330
Last checkpoint at 35793553321
0 pending log flushes, 0 pending chkp writes
323373 log i/o's done, 4.05 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 6476005376
Dictionary memory allocated 729456
Buffer pool size 384720
Free buffers 114421
Database pages 252782
Old database pages 93407
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 983, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 239608, created 13174, written 794983
0.03 reads/s, 0.03 creates/s, 18.28 writes/s
Buffer pool hit rate 999 / 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: 252782, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
----------------------
INDIVIDUAL BUFFER POOL INFO
----------------------
---BUFFER POOL 0
Buffer pool size 48090
Free buffers 14073
Database pages 31811
Old database pages 11759
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 112, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30092, created 1719, written 131533
0.02 reads/s, 0.02 creates/s, 4.47 writes/s
Buffer pool hit rate 999 / 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: 31811, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 1
Buffer pool size 48090
Free buffers 14285
Database pages 31624
Old database pages 11692
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 111, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29985, created 1639, written 95837
0.00 reads/s, 0.00 creates/s, 0.93 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: 31624, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 2
Buffer pool size 48090
Free buffers 14213
Database pages 31657
Old database pages 11705
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 119, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30089, created 1568, written 56444
0.00 reads/s, 0.00 creates/s, 1.60 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: 31657, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 3
Buffer pool size 48090
Free buffers 15270
Database pages 30638
Old database pages 11323
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 136, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 28829, created 1809, written 172234
0.02 reads/s, 0.00 creates/s, 4.33 writes/s
Buffer pool hit rate 999 / 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: 30638, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 4
Buffer pool size 48090
Free buffers 14058
Database pages 31870
Old database pages 11768
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 137, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30401, created 1469, written 111736
0.00 reads/s, 0.02 creates/s, 2.68 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: 31870, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 5
Buffer pool size 48090
Free buffers 13700
Database pages 32215
Old database pages 11911
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 131, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 30630, created 1585, written 91920
0.00 reads/s, 0.00 creates/s, 1.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: 32215, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 6
Buffer pool size 48090
Free buffers 14818
Database pages 31074
Old database pages 11489
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 116, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29606, created 1468, written 67979
0.00 reads/s, 0.00 creates/s, 1.57 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: 31074, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
---BUFFER POOL 7
Buffer pool size 48090
Free buffers 14004
Database pages 31893
Old database pages 11760
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 121, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 29976, created 1917, written 67300
0.00 reads/s, 0.00 creates/s, 0.75 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: 31893, 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
2 read views open inside InnoDB
Process ID=33006, Main thread ID=139702735435520, state: sleeping
Number of rows inserted 296865, updated 190576, deleted 9070, read 8255654063
2.97 inserts/s, 1.15 updates/s, 0.03 deletes/s, 59423.73 reads/s
Number of system rows inserted 0, updated 0, deleted 0, read 5378
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
如果 mysqld 在查询完成之前崩溃,则该查询不会写入慢日志。这是一个不幸的事实 -- 有时 运行ning 长的查询是导致崩溃的一个因素。
如果它没有崩溃,那么我们会深入研究。
请提供SELECT COUNT(*) FROM wedmattp WHERE DocId in( 1638486)
.
并且... SHOW ENGINE=InnoDB STATUS;
在删除 and/or 之后是 运行。
导致“等待 table 级别锁定”的原因并不明显,但涉及删除操作。
连接时使用什么CHARACTER SET
连接(用于删除)?
同时,我建议将 long_query_time
降低到 1
。 (这对当前问题没有帮助,但会帮助您找到更多慢查询。)
更多
The EXPLAIN command says
是 EXPLAIN UPDATE...
还是 EXPLAIN
对等 Select?
请打开慢速日志中的解释,以便我们何时可以在那里显示内容。 (我认为它类似于 log_slow_verbosity=explain)
同时,执行 SHOW EXPLAIN
以获取有关 运行ning 查询.