我们有v10.1
(目前为v10.0
,但同样的事情发生在9 databases
),没有太大,只有几GB的数据,InnoDB
,每个数据库用于不同应用程序,因此它们没有逻辑连接。所有表格均为0-2 times
。
不时(通常每天server
)select
停止处理所有与数据库相关的查询(update
,insert
,alter
,{{1在所有数据库上。它们只是挂起/构建,直到最旧的查询达到大约500s
的锁定时间,然后一切都恢复正常。这些情况未在"deadlocks"
的{{1}}部分中注册。 syslog只显示
" mysqld:150423 12:07:38 [警告]中止连接42到db:' ejd_im'用户:' ejabberd'主持人:' localhost' (未知错误)"。
配置:
"show engine innodb status;"
我还设法从"显示引擎innodb状态捕获部分输出;"关于最早的等待交易:
[mysqld]
skip-external-locking
transaction-isolation = READ-COMMITTED
bind-address = 0.0.0.0
max_connections = 30
connect_timeout = 10
max_allowed_packet = 16M
thread_cache_size = 64
sort_buffer_size = 128M
bulk_insert_buffer_size = 64M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 2M
join_buffer_size = 32M
tmp_table_size = 64M
max_heap_table_size = 64M
query_cache_limit = 4M
query_cache_size = 64M
query_cache_type = 1
log_warnings = 2
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 2
log_slow_verbosity = explain #query_plan
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
binlog_format = 'ROW'
sync_binlog = 0
expire_logs_days = 2
max_binlog_size = 100M
default_storage_engine = InnoDB
innodb_log_file_size = 64M
innodb_buffer_pool_size = 8G
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 1200
innodb_flush_method = O_DIRECT
innodb_defragment = 1
innodb_file_format = Barracuda
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_checksum_algorithm = crc32
innodb_use_fallocate = 1
innodb_autoinc_lock_mode= 2
innodb_ft_sort_pll_degree = 4
有人能告诉我,到底发生了什么事,或者如何诊断这件事?它为什么影响所有数据库?
编辑:apiTiming结构:
---TRANSACTION 71290030, ACTIVE (PREPARED) 411 sec
mysql tables in use 1, locked 1
2 lock struct(s), heap size 360, 1 row lock(s), undo log entries 1
MySQL thread id 153651, OS thread handle 0x7ff144ada700, query id 1459228 localhost nlb query end
REPLACE INTO apiTimings (`userId`, `lastAccess`, `lastIp`, `source`) VALUES ('909', '1429783180', 'xxx.xxx.xxx.xxx', '1')
Trx #rec lock waits 0 #table lock waits 0
Trx total rec lock wait time 0 SEC
Trx total table lock wait time 0 SEC
TABLE LOCK table `nlb`.`apiTimings` trx id 71290030 lock mode IX lock hold time 411 wait time before grant 0
RECORD LOCKS space id 484 page no 5 n bits 280 index `PRIMARY` of table `nlb`.`apiTimings` trx table locks 1 total table locks 27 trx id 71290030 lock_mode X locks rec but not gap loc
k hold time 411 wait time before grant 0
---TRANSACTION 71290022, ACTIVE (PREPARED) 412 sec
mysql tables in use 1, locked 1
2 lock struct(s), heap size 360, 1 row lock(s), undo log entries 1
MySQL thread id 153644, OS thread handle 0x7ff1449b6700, query id 1459203 localhost nlb query end
REPLACE INTO apiTimings (`userId`, `lastAccess`, `lastIp`, `source`) VALUES ('963', '1429783179', 'xx.xx.xx.xx', '1')
Trx #rec lock waits 0 #table lock waits 0
Trx total rec lock wait time 0 SEC
Trx total table lock wait time 0 SEC
TABLE LOCK table `nlb`.`apiTimings` trx id 71290022 lock mode IX lock hold time 412 wait time before grant 0
RECORD LOCKS space id 484 page no 5 n bits 280 index `PRIMARY` of table `nlb`.`apiTimings` trx table locks 1 total table locks 27 trx id 71290022 lock_mode X locks rec but not gap lock hold time 412 wait time before grant 0
---TRANSACTION 71290019, ACTIVE 412 sec doing SYNC index
1 lock struct(s), heap size 360, 0 row lock(s), undo log entries 18987
Trx #rec lock waits 0 #table lock waits 0
Trx total rec lock wait time 0 SEC
Trx total table lock wait time 0 SEC
TABLE LOCK table "nlb"."FTS_0000000000000321_0000000000000724_INDEX_1" trx id 71290019 lock mode IX lock hold time 412 wait time before grant 0
---TRANSACTION 71290018, ACTIVE (PREPARED) 412 sec committing
2 lock struct(s), heap size 360, 0 row lock(s), undo log entries 3
MySQL thread id 153643, OS thread handle 0x7ff132d93700, query id 1459197 localhost nlb init
COMMIT
Trx #rec lock waits 0 #table lock waits 0
Trx total rec lock wait time 0 SEC
Trx total table lock wait time 0 SEC
TABLE LOCK table `nlb`.`posts` trx id 71290018 lock mode IX lock hold time 412 wait time before grant 0
TABLE LOCK table `nlb`.`dashboards` trx id 71290018 lock mode IX lock hold time 412 wait time before grant 0
另一个CREATE TABLE IF NOT EXISTS `apiTimings` (
`userId` int(11) NOT NULL,
`lastAccess` bigint(20) NOT NULL,
`lastIp` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`source` int(11) NOT NULL,
PRIMARY KEY (`userId`),
KEY `source` (`source`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
:
show engine innodb status;