The situation is the following. Two InnoDB tables, one has 2 records, another one - 281 - small ones, insert and update requests may last up to two (!) minutes. Dropped db, created again. The situation repeats in a couple of hours. The tables are history and semaphore from Drupal Commerce (Drupal 7).
Innodb settings:
innodb_fast_shutdown = 0
innodb_buffer_pool_instances = 4
innodb_buffer_pool_size = 1280M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 256M
innodb_log_buffer_size = 4M
innodb_flush_log_at_trx_commit = 0
innodb_additional_mem_pool_size = 4M
innodb_lock_wait_timeout = 180
Tables:
CREATE TABLE `history` (
`uid` int(11) NOT NULL DEFAULT '0' COMMENT 'The users.uid that read the node nid.',
`nid` int(11) NOT NULL DEFAULT '0' COMMENT 'The node.nid that was read.',
`timestamp` int(11) NOT NULL DEFAULT '0' COMMENT 'The Unix timestamp at which the read occurred.',
PRIMARY KEY (`uid`,`nid`),
KEY `nid` (`nid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='A record of which users have read which...';
CREATE TABLE `semaphore` (
`name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique name.',
`value` varchar(255) NOT NULL DEFAULT '' COMMENT 'A value for the semaphore.',
`expire` double NOT NULL COMMENT 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
PRIMARY KEY (`name`),
KEY `value` (`value`),
KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table for holding semaphores, locks, flags, etc. that...';
Upd.
show processlist;
+------+---------------+---------------------+----------+---------+------+----------+--------------------------------------------------------------------------------------------------+----------+
| Id | User | Host | db | Command | Time | State | Info | Progress |
+------+---------------+---------------------+----------+---------+------+----------+--------------------------------------------------------------------------------------------------+----------+ | 0.000 |
| 7996 | myuser | localhost | mydb | Query | 129 | updating | DELETE FROM semaphore
WHERE (value = '584023605761bad5c4a925.89704284') | 0.000 |
| 8003 | myuser | localhost | mydb | Query | 112 | updating | UPDATE history SET timestamp='1466022629'
WHERE ( (uid = '1') AND (nid = '40') ) | 0.000 | | 0.000 |
| 8018 | myuser | localhost | mydb | Query | 53 | updating | DELETE FROM semaphore
WHERE (value = '6705735415761bb221d33c0.93445495') | 0.000 |
+------+---------------+---------------------+----------+---------+------+----------+--------------------------------------------------------------------------------------------------+----------+
Upd2.
explain UPDATE history SET timestamp='1466022629' WHERE ( (uid = '1') AND (nid = '40') );
+------+-------------+-------------------------+-------+---------------+---------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------------------------+-------+---------------+---------+---------+------+------+-------------+
| 1 | SIMPLE | history | range | PRIMARY,nid | PRIMARY | 8 | NULL | 1 | Using where |
+------+-------------+-------------------------+-------+---------------+---------+---------+------+------+-------------+
1 row in set (0.01 sec)
innodb_additional_mem_pool_sizeis set twice so probably the smaller value is used. – jkavalik Jun 15 '16 at 18:54show full processlist;andshow engine innodb status\Gduring one such occurence. – jkavalik Jun 15 '16 at 18:56WHERE (uid = '1') AND (nid = '40'). Try changing that to:WHERE (uid = 1) AND (nid = 40)– ypercubeᵀᴹ Jun 15 '16 at 22:39TRANSACTION 3758562, ACTIVE 52 seccurrently probably "sleeping" but still holding4158 row lock(s)so it is quite probable the other statements just wait until it commits or otherwise ends. – jkavalik Jun 16 '16 at 14:30innodb_additional_mem_pool_sizeshould not matter -- it was deprecated in 5.6.3. – Rick James Jun 27 '16 at 21:03uidandnidareINTs; so quoting the numbers is not harmful. (VARCHARvs non-quoted numbers is another issue.) – Rick James Jun 27 '16 at 21:05innodb_lock_wait_timeout? Since those 3 queries have exceeded the 50-second default, have you raised the value? Or is something else going on? – Rick James Jun 27 '16 at 21:07