Skip to content

Commit e033f7f

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

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
@@ -912,31 +912,26 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
912912
{
913913
$judging = $this->em->getRepository(Judging::class)->find($judgingId);
914914
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-
}
915+
$q = $this->em->createQueryBuilder()
916+
->update(JudgingRun::class, 'jr')
917+
->join(JudgeTask::class, 'jt')
918+
->andWhere('jr.runresult IS NOT NULL')
919+
->andWhere('jr.judgingid = :judgingid')
920+
->setParameter('judgingid', $judgingId);
929921

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-
}
922+
if ($judgehost === null) {
923+
// This is coming from internal errors, reset the whole judging.
924+
$q->set('jt.valid', 0);
925+
} else {
926+
$q->andWhere('jr.run_result IS NOT NULL')
927+
->join(JudgeHost::class, 'jh')
928+
->set('jt.judgehostid', null)
929+
->set('jt.starttime', null)
930+
->andWhere('jh.hostname = :judgehost')
931+
->setParameter('judgehost', $judgehost->getHostname());
932+
}
937933

938-
$this->em->flush();
939-
});
934+
$q->getQuery()->execute();
940935

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

0 commit comments

Comments
 (0)