Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 14f4141

Browse files
committed
Do not use transaction while handing back judging
1 parent 81497f7 commit 14f4141

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

‎webapp/src/Controller/API/JudgehostController.php‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -910,37 +910,22 @@ public function internalErrorAction(Request $request): ?int
910910
*/
911911
protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
912912
{
913+
// Reset the judgings without using Doctrine, it has no support for update queries containing a join.
914+
// Both databases supported by DOMjudge (MariaDB, MySQL) support these types of queries.
913915
$judging = $this->em->getRepository(Judging::class)->find($judgingId);
914916
if ($judging) {
915-
$this->em->wrapInTransaction(function () use ($judging, $judgehost) {
916-
/** @var JudgingRun $run */
917-
foreach ($judging->getRuns() as $run) {
918-
if ($judgehost === null) {
919-
// This is coming from internal errors, reset the whole judging.
920-
$run->getJudgetask()
921-
->setValid(false);
922-
continue;
923-
}
924-
925-
// We do not have to touch any finished runs
926-
if ($run->getRunresult() !== null) {
927-
continue;
928-
}
929-
930-
// For the other runs, we need to reset the judge task if it belongs to the current judgehost.
931-
if ($run->getJudgetask()->getJudgehost() && $run->getJudgetask()->getJudgehost()->getHostname() === $judgehost->getHostname()) {
932-
$run->getJudgetask()
933-
->setJudgehost(null)
934-
->setStarttime(null);
935-
}
936-
}
937-
938-
$this->em->flush();
939-
});
940-
941917
if ($judgehost === null) {
942918
// Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by
943919
// an internal error.
920+
$this->em->getConnection()->executeStatement(
921+
'UPDATE judgingrun jr ' .
922+
'JOIN judgingtask jt ON jt.judgetaskid = jr.judgetaskid ' .
923+
'SET jt.valid = 0 ' .
924+
'WHERE jr.judgingid = :judgingid',
925+
[
926+
'judgingid' => $judgingId,
927+
]);
928+
944929
$judging->setValid(false);
945930
$newJudging = new Judging();
946931
$newJudging
@@ -950,6 +935,19 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
950935
->setOriginalJudging($judging);
951936
$this->em->persist($newJudging);
952937
$this->em->flush();
938+
} else {
939+
// Hand back the non-completed work of this judgehost within this judgetask.
940+
$this->em->getConnection()->executeStatement(
941+
'UPDATE judgingrun jr ' .
942+
'JOIN judgingtask jt ON jt.judgetaskid = jr.judgetaskid ' .
943+
'SET jt.judgehostid = null, jt.starttime = null ' .
944+
'WHERE jr.judgingid = :judgingid ' .
945+
' AND jr.run_result IS NOT NULL ' .
946+
' AND jt.judgehostid = :judgehost',
947+
[
948+
'judgingid' => $judgingId,
949+
'judgehost' => $judgehost->getJudgehostid(),
950+
]);
953951
}
954952

955953
$this->dj->auditlog('judging', $judgingId, 'given back'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /