I had many years, and I could not figure it out. I have no idea what might cause these locks.
Error: Lock wait timeout exceeded; try restarting transaction SQLState: 41000 VendorError: 1205 Lock wait timeout exceeded; try restarting transaction SQLState: 41000 VendorError: 1205
An SQL statement is a single insert statement that runs inside a transaction. All inserts have this shape, so there are no built-in inserts or inserts in blend mode, etc.
INSERT INTO attachment( id, entityid, entitytype , addeduserid , deleteduserid , fullpath , filename, status, creationdate, lastupdated, deletiondate, hasfile,notes,history,type,mimeinfo,archivedby,archivedon, referencedate,changedby,changedon ) values (0,0,2,360,null,NULL,NULL,1,'2013-02-20 08:45:31','2013-02-20 08:45:31',NULL,0,NULL,'20/02/2013 08:45:UserA:File uploaded internally. <br>',0,NULL,null,NULL,NULL,null,NULL);
System Configuration: Mysql Version: "Server Version: 5.1.61 Source Distribution" (on Redhat)
Storage: INNODB
INNODB related configuration (partially edited from my.cnf):
innodb_file_per_table=1 innodb_buffer_pool_size=3G innodb_additional_mem_pool_size=20M innodb_log_file_size=512M innodb_log_files_in_group=2 innodb_log_buffer_size=16M innodb_support_xa=1 innodb_doublewrite=1 innodb_thread_concurrency=0 innodb_flush_log_at_trx_commit=2 innodb_autoinc_lock_mode=2** innodb_rollback_on_timeout=1 innodb_locks_unsafe_for_binlog=1** thread_cache_size=8 query_cache_size=256M query_cache_limit=4M table_cache=2048 table_definition_cache=1024 tmp_table_size=512M max_heap_table_size=512M transaction-isolation=READ-COMMITTED** innodb_table_locks=0** innodb_lock_wait_timeout=50**
** They have been specially added in connection with this problem.
Usually:
The system (that is, it has 6 instances of applications, each of which has the same database structure that runs in the same mysql instance) can work normally for several days, and then it can start when the "Block expectations" function starts occur and will usually appear in groups throughout the day. Each individual error will occur repeatedly, because as soon as it fails, I will try again, and usually a second attempt will fail. I set up a retry 4 times. Often locks will only occur on a few different tables.
Today's specific instance of the problem:
This morning on the attachment table from last night there was no insert on the table. There were no updates since the previous night either. If the locks are not associated with other users doing updates and inserts, can certain select statements cause locks? I tried to ensure that all select statements use attachment_general_index ?
Due to the fact that I basically get this for a couple of different tables - here is the structure of this table.
CREATE TABLE `attachment` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `entityid` int(10) unsigned DEFAULT NULL, `entitytype` tinyint(3) unsigned NOT NULL DEFAULT '0', `addeduserid` int(10) unsigned NOT NULL, `deleteduserid` int(10) unsigned DEFAULT NULL, `fullpath` varchar(255) DEFAULT NULL, `filename` varchar(255) DEFAULT NULL, `status` tinyint(3) unsigned NOT NULL DEFAULT '0', `creationdate` varchar(40) DEFAULT NULL, `lastupdated` varchar(40) DEFAULT NULL, `deletiondate` varchar(40) DEFAULT NULL, `hasfile` tinyint(3) unsigned NOT NULL DEFAULT '0', `notes` text, `history` text, `type` tinyint(3) unsigned DEFAULT '0', `lastupdatedby` int(10) DEFAULT '0', `lastupdatedinfo` varchar(255) DEFAULT NULL, `mimeinfo` varchar(255) DEFAULT NULL, `archivedby` int(10) unsigned DEFAULT NULL, `archivedon` varchar(40) DEFAULT NULL, `referencedate` varchar(40) DEFAULT NULL, `changedby` int(10) unsigned DEFAULT NULL, `changedon` varchar(40) DEFAULT NULL, PRIMARY KEY (`id`), KEY `attachment_addeduserid_fkey` (`addeduserid`), KEY `attachment_deleteduserid_fkey` (`deleteduserid`), KEY `attachment_archivedby_fkey` (`archivedby`), KEY `attachment_changedby_fkey` (`changedby`), KEY `attachment_general_index` (`entitytype`,`entityid`,`status`,`type`), CONSTRAINT `attachment_ibfk_1` FOREIGN KEY (`addeduserid`) REFERENCES `user` (`id`), CONSTRAINT `attachment_ibfk_2` FOREIGN KEY (`deleteduserid`) REFERENCES `user` (`id`), CONSTRAINT `attachment_ibfk_3` FOREIGN KEY (`archivedby`) REFERENCES `user` (`id`), CONSTRAINT `attachment_ibfk_4` FOREIGN KEY (`changedby`) REFERENCES `user` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3619 DEFAULT CHARSET=latin1$$
I attached the recent SHOW INNODB STATUS, this is from today, and since yesterday there has been no blockage. I donβt understand this whole exit, but the main thing is that castles never appear here. I believe that they are not classified as deadlocks?
https://docs.google.com/document/d/1Hslf2B594n8ofAUYxN54Gh8FrSCIFNGGMtthVI_Lv4k/pub
Is this interesting only for the area of ββdead castles? If there are other areas, I will try to collect when this happens and can provide.
Any help would be appreciated.
Nick