@@ -910,37 +910,22 @@ public function internalErrorAction(Request $request): ?int
910
910
*/
911
911
protected function giveBackJudging (int $ judgingId , ?Judgehost $ judgehost ): void
912
912
{
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.
913
915
$ judging = $ this ->em ->getRepository (Judging::class)->find ($ judgingId );
914
916
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
-
941
917
if ($ judgehost === null ) {
942
918
// Invalidate old judging and create a new one - but without judgetasks yet since this was triggered by
943
919
// 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
+
944
929
$ judging ->setValid (false );
945
930
$ newJudging = new Judging ();
946
931
$ newJudging
@@ -950,6 +935,19 @@ protected function giveBackJudging(int $judgingId, ?Judgehost $judgehost): void
950
935
->setOriginalJudging ($ judging );
951
936
$ this ->em ->persist ($ newJudging );
952
937
$ 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
+ ]);
953
951
}
954
952
955
953
$ this ->dj ->auditlog ('judging ' , $ judgingId , 'given back '
0 commit comments