after querying the current thread, it was found that multiple threads were running at the same time…
to view all currently running transactions:
SELECT * FROM information_schema.INNODB_TRX;
you can find three transactions all running at the same time… So you can find the direct cause of the error reported by the shopkeeper here is:
before the stored procedure (which opened the transaction) ran for half a day, MySQL was manually closed without any response… Didn’t make it commit… And the subsequent deletion of data in the same transaction creates a transaction lock…
The fundamental reason is that MySQL USES the Innodb engine by default, and the default parameter of Innodb: innodb_lock_wait_timeout, which sets the maximum time for transactions to wait for acquiring resources (default 50s). Once the maximum time is exceeded, it will report errors such as questions without obtaining resources.
Well, now that the cause of the error has been identified, there are three solutions:
Find the thread of the current transaction, kill the thread; Enlarge this parameter: innodb_lock_wait_TIMEOUT wait time; Optimize stored procedures.
Here the shopkeeper takes the first approach, killing the redundant threads and then checking all the currently running transactions again:
find something strange?The killed thread Number 10 is still working??Its current state is “ROLLING BACK,” which means that the transaction that was killed a while ago has been in a rollback state. So the shopkeeper continued to look up materials and found that such a situation occurred because although the kill command was triggered, it took a long time to terminate the kill logic, and it was also affected by IO resources. Therefore, rollback occurred even though the kill was executed.
Solutions:
One is to wait for it to roll back; Another is to restart the MySQL, but restart MySQL, the transaction will roll back, so in general is actually etc. It can be rolled back end 😂!
waited for about seven or eight minutes before everything was cleared, and all transactions were over:
and then delete again:
Read More:
- Lock wait timeout exceeded — transaction and index
- [338] MySQL error: error 1205: lock wait timeout exceeded solution
- Global lock, table lock and row lock in MySQL
- When linux installs rpm, it prompts: can’t create transaction lock on /var/lib/rpm/.rpm.lock error
- Uncaught (in promise) Error: timeout of 5000ms exceeded
- Centos 7 | mariadb/mysql | [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
- Error: timeout of 5000ms exceeded error is always reported during post request
- Error: current transaction is aborted, commands ignored until end of transaction blockp
- Solve MySQL error 2002 (HY000)
- Get connection timeout retry: 1 MySQL errorcode 0, state 08s01 docker container accessing MySQL container is very slow and sometimes interrupted
- Solution to error 2002 (HY000) in MySQL login startup
- ERROR 2005 (HY000): Unknown MySQL server host
- Error 2005 (HY000) unkonw MySQL server host…
- Mysql start slave error 1201 (HY000)
- ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
- Solution to error 2002 (HY000) in MySQL
- node.js Server MySQL database connection timeout (error: connect etimeout)
- Error 2003 (HY000): can’t connect to MySQL server on ‘localhost’ (10061)
- [TCP] TCP connection SYN timeout retransmission times and timeout period
- [MySQL] error 1396 (HY000): Operation create user failed for ‘MySQL’ @’localhost ‘