gpt4 book ai didi

php - 当 php 代码没有达到 release-mysql-lock 阶段时会发生什么?

转载 作者:可可西里 更新时间:2023-11-01 07:50:01 26 4
gpt4 key购买 nike

作为例子,用这个脚本;

mysql_query("LOCK TABLES mytest WRITE;");

for ($i = 1; $i < 100000; ++$i) {
mysql_query("INSERT INTO mytest (Value, Value2, Value3) VALUES ($i, $i, $i);");
}

mysql_query("UNLOCK TABLES;");

如果在到达 UNLOCK TABLES 阶段之前脚本超时/用户计算机崩溃/其他情况会发生什么? mysql会“注意到”请求锁的客户端已经断开并适当释放锁,还是会无限卡住?

最佳答案

根据MySQL文档:

If the connection for a client session terminates, whether normally or abnormally, the server implicitly releases all table locks held by the session (transactional and nontransactional). If the client reconnects, the locks will no longer be in effect.

关于php - 当 php 代码没有达到 release-mysql-lock 阶段时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10262063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com