How to display outstanding transactions in MySQL
P粉176151589
P粉176151589 2023-08-27 16:03:45
0
2
452
<p>I ran some queries without submitting. Then the application is stopped. </p> <p>How do I display these open transactions and submit or cancel them? </p>
P粉176151589
P粉176151589

reply all(2)
P粉463824410

Although there won't be any remaining transactions in this case, as @Johan said, if you wish, you can view the current list of transactions in InnoDB via the query below.

Select *

from information_schema.innodb_trx\G

From Documentation:

P粉726133917

Without an open transaction, MySQL will roll back the transaction on disconnect.
You cannot commit the transaction (IFAIK).

You display threads using

SHOW FULL PROCESSLIST

See: http://dev.mysql.com/ doc/refman/5.1/en/thread-information.html

This won't help you since you can't commit a transaction from a broken connection.

What happens when the connection is interrupted
From the MySQL documentation: http://dev.mysql.com/ doc/refman/5.0/en/mysql-tips.html

See also: http://dev.mysql.com /doc/refman/5.0/en/auto-reconnect.html

How to diagnose and resolve this issue
Check for automatic reconnection:

Make sure to keep the last query (transaction) in the client so that you can resubmit it if needed.
And disable automatic reconnect mode as this is dangerous, implement your own reconnect instead so you know when a drop occurs and can resubmit that query.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!