No. After the client connection is disconnected, the lock will be automatically released.
Client 1
set AUTOCOMMIT = 0;
BEGIN;
SELECT * FROM articles WHERE id=1 FOR UPDATE ;
Client 2
set AUTOCOMMIT = 0;
BEGIN;
SELECT * FROM articles WHERE id=1 FOR UPDATE ;
At this time, client 2’s query will be stuck. Until client 1 commit or rollback . However, if client 1 directly closes the window and disconnects, client 2 can also directly obtain the lock. Explain that when the client disconnects, the lock will be automatically released. commit 或 rollback 。但是,如果客户端1直接关闭窗口断开连接,客户端2也能直接拿到锁。说明客户端断开时,会自动释放锁。
那么问题来了,客户端1断开连接后,是自动 rollback
Then the question is, after client 1 disconnects, does it automatically rollback? 🎜
No. After the client connection is disconnected, the lock will be automatically released.
Client 1
Client 2
At this time, client 2’s query will be stuck. Until client 1
commit
orrollback
. However, if client 1 directly closes the window and disconnects, client 2 can also directly obtain the lock. Explain that when the client disconnects, the lock will be automatically released.commit
或rollback
。但是,如果客户端1直接关闭窗口断开连接,客户端2也能直接拿到锁。说明客户端断开时,会自动释放锁。那么问题来了,客户端1断开连接后,是自动
Then the question is, after client 1 disconnects, does it automaticallyrollback
rollback
? 🎜