error
The sentry background sees the error There is no active transaction
, which occurs in a update method, roughly
function update() {
$this->db->beginTrans();
try {
dosomething();
$this->db->commitTrans();
} catch (\Exception $ex) {
this->db->rollBackTrans();
throw $ex;
}
}
I also checked the dosomething ()
method carefully. There is no place to open the transaction and end the transaction, and the error position is on the line $this- > db- > commitTrans ();
. It"s a bit strange why there are no transactions?
db class
I guess it"s the db class (no transaction is opened). This class is changed by me with workman mysql helper (adding a master-slave read). The source code is here , and I open the transaction part is
.public function beginTrans()
{
$this->Trans = true;
try {
return $this->pdo->beginTransaction();
} catch (PDOException $e) {
//
if ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013) {
$this->closeConnection();
$this->pdoRW = $this->getConnectionInstance($this->configs["rw"]);
$this->pdo = $this->pdoRW;
return $this->pdo->beginTransaction();
} else {
throw $e;
}
}
}
however, transactions are also started, and it is strange that the cause of the problem occurs (this problem sometimes occurs)