mysql如果一个事务一直没有commit并且也没有rollback会怎样?
有什么办法查询到这些没有被commit也没有被rollback的事务。?
PHPz2017-04-17 13:48:53
If there is an uncommitted transaction in MySQL, then the AUTOCOMMIT automatic submission parameter should be 0 at this time.
However, if you operate through MySQL drivers in other languages, these drivers generally have the function of automatically recovering AUTOCOMMIT. After the request processing is completed, unprocessed transactions will be automatically ROLLBACKed.
阿神2017-04-17 13:48:53
When the connection times out, transactions that have not been committed on that connection will be rolled back
ringa_lee2017-04-17 13:48:53
1. When the link is disconnected, it will automatically rollback
2. When there is a deadlock or the lock times out, it will also rollback
黄舟2017-04-17 13:48:53
When the database connection is disconnected or the request ends, it will usually rollback automatically
This is the answer everyone will give, but is it actually the rollback of the server, the startup environment (FPM), or the connection library operation of the code? ? ? Not sure, but my guess is that the tool class connected to the database automatically rollbacks, or the startup environment (FPM) automatically rollbacks directly when the server is ready to return data to the client
There are also official documents on the Internet, for example, PHP-mysql is a rollback automatically called by PDO (database driver library). But it didn’t say when exactly it would be disconnected. . .