search

Home  >  Q&A  >  body text

How to display outstanding transactions in MySQL

<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粉176151589P粉176151589460 days ago470

reply all(2)I'll reply

  • P粉463824410

    P粉4638244102023-08-28 11:18:36

    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:

    reply
    0
  • P粉726133917

    P粉7261339172023-08-28 09:36:30

    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.

    reply
    0
  • Cancelreply