Skip to content

Commit beeb7b3

Browse files
elderingnickygerritsen
authored andcommitted
Create judging_run_output together with judging_run rows
This means that the data state is more consistent. Also, before the fix bb5d4c8, the judgedaemon would retry the API call leading here after a 500 response and then try to recreate the judging_run_output row of the associated judging_run, which was already created in the first API call, leading to an error ``` [Nov 23 14:47:57.923] judgedaemon[813572]: warning: Error while executing curl POST to url http://localhost/domjudge/api/judgehosts/add-judging-run/tiger-1/2589899: http status code: 500, request size = 5400, response: array ( 'code' => 500, 'message' => 'An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry \'2575471\' for key \'PRIMARY\'', ```
1 parent 0065f51 commit beeb7b3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

webapp/src/Controller/API/JudgehostController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,13 +948,13 @@ private function addSingleJudgingRun(
948948
throw new BadRequestHttpException(
949949
'Inconsistent data, no judging run known with judgetaskid = ' . $judgeTaskId . '.');
950950
}
951-
$judgingRunOutput = new JudgingRunOutput();
952-
$judgingRun->setOutput($judgingRunOutput);
953951
$judgingRun
954952
->setRunresult($runResult)
955953
->setRuntime((float)$runTime)
956954
->setEndtime(Utils::now())
957955
->setTestcasedir($testcasedir);
956+
957+
$judgingRunOutput = $judgingRun->getOutput();
958958
$judgingRunOutput
959959
->setOutputRun(base64_decode($outputRun))
960960
->setOutputDiff(base64_decode($outputDiff))

webapp/src/Service/DOMJudgeService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,13 +1649,19 @@ private function actuallyCreateJudgetasks(int $priority, Judging $judging, int $
16491649

16501650
$this->em->getConnection()->executeQuery($judgetaskInsertQuery, $judgetaskInsertParamsWithoutColon);
16511651

1652-
// Step 3: Insert the corresponding judging runs.
1652+
// Step 3: Insert the corresponding judging runs and output.
16531653
$this->em->getConnection()->executeQuery(
16541654
'INSERT INTO judging_run (judgingid, judgetaskid, testcaseid)
16551655
SELECT :judgingid, judgetaskid, testcase_id FROM judgetask
16561656
WHERE jobid = :judgingid ORDER BY judgetaskid',
16571657
['judgingid' => $judging->getJudgingid()]
16581658
);
1659+
1660+
$this->em->getConnection()->executeQuery(
1661+
'INSERT INTO judging_run_output (runid)
1662+
SELECT runid FROM judging_run WHERE judgingid = :judgingid',
1663+
['judgingid' => $judging->getJudgingid()]
1664+
);
16591665
}
16601666

16611667
public function shadowMode(): bool

0 commit comments

Comments
 (0)