变更
This commit is contained in:
+3
-1
@@ -157,7 +157,7 @@ class Command extends Component
|
|||||||
return $result == 0 ? true : $result;
|
return $result == 0 ? true : $result;
|
||||||
} catch (\PDOException|\Throwable $throwable) {
|
} catch (\PDOException|\Throwable $throwable) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
||||||
Context::remove('master:client');
|
$this->db->restore(true);
|
||||||
|
|
||||||
unset($pdo);
|
unset($pdo);
|
||||||
return $this->_execute();
|
return $this->_execute();
|
||||||
@@ -187,6 +187,8 @@ class Command extends Component
|
|||||||
return $statement;
|
return $statement;
|
||||||
} catch (\PDOException|\Throwable $throwable) {
|
} catch (\PDOException|\Throwable $throwable) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
||||||
|
$this->db->restore(false);
|
||||||
|
|
||||||
unset($pdo);
|
unset($pdo);
|
||||||
return $this->queryPrev($this->db->getSlaveClient());
|
return $this->queryPrev($this->db->getSlaveClient());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,6 +253,17 @@ class Connection extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function restore($isMaster)
|
||||||
|
{
|
||||||
|
if ($isMaster) {
|
||||||
|
Context::remove($this->cds . 'master');
|
||||||
|
} else {
|
||||||
|
$slave = ($this->slaveConfig['cds'] ?? $this->cds) . 'slave';
|
||||||
|
Context::remove($slave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 回收链接
|
* 回收链接
|
||||||
|
|||||||
Reference in New Issue
Block a user