Skip to content

Commit fe1a536

Browse files
committed
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 9215dd5 commit fe1a536

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
@@ -1647,13 +1647,19 @@ private function actuallyCreateJudgetasks(int $priority, Judging $judging, int $
16471647

16481648
$this->em->getConnection()->executeQuery($judgetaskInsertQuery, $judgetaskInsertParamsWithoutColon);
16491649

1650-
// Step 3: Insert the corresponding judging runs.
1650+
// Step 3: Insert the corresponding judging runs and output.
16511651
$this->em->getConnection()->executeQuery(
16521652
'INSERT INTO judging_run (judgingid, judgetaskid, testcaseid)
16531653
SELECT :judgingid, judgetaskid, testcase_id FROM judgetask
16541654
WHERE jobid = :judgingid ORDER BY judgetaskid',
16551655
['judgingid' => $judging->getJudgingid()]
16561656
);
1657+
1658+
$this->em->getConnection()->executeQuery(
1659+
'INSERT INTO judging_run_output (runid)
1660+
SELECT runid FROM judging_run WHERE judgingid = :judgingid',
1661+
['judgingid' => $judging->getJudgingid()]
1662+
);
16571663
}
16581664

16591665
public function shadowMode(): bool

0 commit comments

Comments
 (0)