MySQL rollback on transaction with lost/disconnected connection

前端 未结 1 1797
暖寄归人
暖寄归人 2020-12-04 17:13

I need to make MySQL server to rollback transaction immediately after its client disconnected, because each client works concurrently. The problem can be reproduced like the

相关标签:
1条回答
  • 2020-12-04 17:34

    When you are physically disconnecting a client you're not sending a normal disconnect (which would have caused a rollback) and the MySQL protocol isn't very chatty so the server never knows that the client isn't there. I think this is a flaw in the protocol when comparing to other database systems where the client and server talks internally much more.

    Anyway. There are two variables that you could change. They basically do the same but for different clients.

    The first is wait_timeout and it is used by application clients like java or php.

    The other is interactive_timeout and it is used by the mysql client (as in your tests)

    In both cases the server to kills the connection after a number of seconds and when doing so rollbacks all transactions and releases all locks.

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