1205, ‘Lock wait timeout exceeded; try restarting transaction’

Recently we had an issue with very long-lived locks on certain rows in MySQL/MariaDB. Certain people (each row representing a person) would get locked out of updates for hours at a time. Using Flask/uWSGI/MariaDB/mysqldb.

SHOW ENGINE INNODB didn’t report any recent deadlocks or other issues but SHOW PROCESSLIST showed some very long sleeping processes and when these were killed the locks would go away. SELECT trx_started, trx_mysql_thread_id FROM information_schema.innodb_trx t JOIN information_schema.processlist p ON t.trx_mysql_thread_id = p.id; was also interesting showing some unclosed transactiosn that corresponded.

We seem to have cleared the problem up by explicitly closing the database connection on teardown_request.

Leave a Reply

Your email address will not be published.