Skip to content

Commit a9f313e

Browse files
committed
Do not use transaction while handing back judging
1 parent d352b47 commit a9f313e

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

webapp/src/Controller/API/JudgehostController.php

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -911,31 +911,26 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
911911
{
912912
$judging = $this->em->getRepository(Judging::class)->find($judgingId);
913913
if ($judging) {
914-
$this->em->wrapInTransaction(function () use ($judging, $judgehost) {
915-
/** @var JudgingRun $run */
916-
foreach ($judging->getRuns() as $run) {
917-
if ($judgehost === null) {
918-
// This is coming from internal errors, reset the whole judging.
919-
$run->getJudgetask()
920-
->setValid(false);
921-
continue;
922-
}
923-
924-
// We do not have to touch any finished runs
925-
if ($run->getRunresult() !== null) {
926-
continue;
927-
}
914+
$q = $this->em->createQueryBuilder()
915+
->update(JudgingRun::class)
916+
->join(JudgeTask::class, 'jt')
917+
->where('jr.runresult IS NOT NULL')
918+
->where('jr.judgingid = :judgingid')
919+
->setParameter('judgingid', $judgingId);
928920

929-
// For the other runs, we need to reset the judge task if it belongs to the current judgehost.
930-
if ($run->getJudgetask()->getJudgehost() && $run->getJudgetask()->getJudgehost()->getHostname() === $judgehost->getHostname()) {
931-
$run->getJudgetask()
932-
->setJudgehost(null)
933-
->setStarttime(null);
934-
}
935-
}
921+
if ($judgehost === null) {
922+
// This is coming from internal errors, reset the whole judging.
923+
$q->set('jt.valid', 0);
924+
} else {
925+
$q->andWhere('jr.run_result IS NOT NULL')
926+
->join(JudgeHost::class, 'jh')
927+
->set('jt.judgehostid', null)
928+
->set('jt.starttime', null)
929+
->andWhere('jh.hostname = :judgehost')
930+
->setParameter('judgehost', $judgehost->getHostname());
931+
}
936932

937-
$this->em->flush();
938-
});
933+
$q->getQuery()->execute();
939934

940935
if ($judgehost === null) {
941936
// Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by

0 commit comments

Comments
 (0)