This commit is contained in:
Dennis Eichhorn 2024-03-10 02:24:57 +00:00
parent 006a611a07
commit 2a41801b77
2 changed files with 55 additions and 5 deletions

View File

@ -163,9 +163,25 @@ final class UpdateMapper extends DataMapperAbstract
}
$sth = $this->db->con->prepare($query->toSql());
if ($sth !== false) {
$sth->execute();
if ($sth === false) {
throw new \Exception();
}
$deadlock = 0;
do {
$repeat = false;
try {
++$deadlock;
$sth->execute();
} catch (\Throwable $t) {
if ($deadlock > 3 || $t->errorInfo[1] !== 1213) {
throw $t;
}
\usleep(10000);
$repeat = true;
}
} while($repeat);
} catch (\Throwable $t) {
// @codeCoverageIgnoreStart
\phpOMS\Log\FileLogger::getInstance()->error(

View File

@ -159,7 +159,25 @@ final class WriteMapper extends DataMapperAbstract
}
$sth = $this->db->con->prepare($query->toSql());
$sth->execute();
if ($sth === false) {
throw new \Exception();
}
$deadlock = 0;
do {
$repeat = false;
try {
++$deadlock;
$sth->execute();
} catch (\Throwable $t) {
if ($deadlock > 3 || $t->errorInfo[1] !== 1213) {
throw $t;
}
\usleep(10000);
$repeat = true;
}
} while($repeat);
$objId = empty($id = $this->mapper::getObjectId($obj)) ? $this->db->con->lastInsertId() : $id;
\settype($objId, $this->mapper::COLUMNS[$this->mapper::PRIMARYFIELD]['type']);
@ -399,9 +417,25 @@ final class WriteMapper extends DataMapperAbstract
}
$sth = $this->db->con->prepare($relQuery->toSql());
if ($sth !== false) {
$sth->execute();
if ($sth === false) {
throw new \Exception();
}
$deadlock = 0;
do {
$repeat = false;
try {
++$deadlock;
$sth->execute();
} catch (\Throwable $t) {
if ($deadlock > 3 || $t->errorInfo[1] !== 1213) {
throw $t;
}
\usleep(10000);
$repeat = true;
}
} while($repeat);
} catch (\Throwable $t) {
// @codeCoverageIgnoreStart
\phpOMS\Log\FileLogger::getInstance()->error(