mysql 开启断线重连_[BUG反馈]MYSQL长连接中(SWOOLE) 使用事务提交开启断线重连接抛出异常...
官方源代码
vendor/topthink/think-orm/src/db/PDOConnection.php :1369行public function startTrans(): void
{
$this->initConnect(true);
++$this->transTimes;
try {
if (1 == $this->transTimes) {
$this->linkID->beginTransaction();
} elseif ($this->transTimes > 1 && $this->supportSavepoint()) {
$this->linkID->exec(
$this->parseSavepoint('trans' . $this->transTimes)
);
}
$this->reConnectTimes = 0;
} catch (\Exception $e) {
if ($this->reConnectTimes isBreak($e)) {
--$this->transTimes;
++$this->reConnectTimes;
$this->close()->startTrans();
}
throw $e;
}
}修复建议: 在"throw $e;"上面加个else或 使用return阻止抛出异常public function startTrans(): void
{
$this->initConnect(true);
++$this->transTimes;
try {
if (1 == $this->transTimes) {
$this->linkID->beginTransaction();
} elseif ($this->transTimes > 1 && $this->supportSavepoint()) {
$this->linkID->exec(
$this->parseSavepoint('trans' . $this->transTimes)
);
}
$this->reConnectTimes = 0;
} catch (\Exception $e) {
if ($this->reConnectTimes isBreak($e)) {
--$this->transTimes;
++$this->reConnectTimes;
$this->close()->startTrans();
}else{
throw $e;
}
}
}
总结
以上是生活随笔为你收集整理的mysql 开启断线重连_[BUG反馈]MYSQL长连接中(SWOOLE) 使用事务提交开启断线重连接抛出异常...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 用python解决实际问题_Python
- 下一篇: mysql时间变成季度_Mysql 时间