How do I determine if I have uncommitted writes in a MySQL transaction?

后端 未结 1 1696
名媛妹妹
名媛妹妹 2021-01-15 09:12

I\'m working with a very complex codebase and wish to do some introspection of how it works with MySQL. (Note that I\'m using InnoDB).

Specifically, in a method I\'

相关标签:
1条回答
  • 2021-01-15 09:44

    This is a pretty interesting question. I don't think there is a definite way to determine if issuing commit will or will not make a difference in the session you are running.

    You can see transactions with show innodb status or show engine innodb status but I don't think you can issue commit on those transactions.

    INNODB_TRX table in information_schema will show currently executing transations: https://dev.mysql.com/doc/refman/5.5/en/innodb-trx-table.html and again there's not much you can do to force-commit them. You can roll them back by killing the associated process.

    If you are running a transaction using START TRANSACTION in a stored procedure, you can handle commit and rollback manually. You can even set autocommit to 0 to control when to rollback and when to commit.

    0 讨论(0)
提交回复
热议问题