Skip to content

Commit

Permalink
Create judging_run_output together with judging_run rows
Browse files Browse the repository at this point in the history
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\'',
```
  • Loading branch information
eldering authored and nickygerritsen committed Nov 24, 2024
1 parent 0065f51 commit beeb7b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions webapp/src/Controller/API/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,13 @@ private function addSingleJudgingRun(
throw new BadRequestHttpException(
'Inconsistent data, no judging run known with judgetaskid = ' . $judgeTaskId . '.');
}
$judgingRunOutput = new JudgingRunOutput();
$judgingRun->setOutput($judgingRunOutput);
$judgingRun
->setRunresult($runResult)
->setRuntime((float)$runTime)
->setEndtime(Utils::now())
->setTestcasedir($testcasedir);

$judgingRunOutput = $judgingRun->getOutput();
$judgingRunOutput
->setOutputRun(base64_decode($outputRun))
->setOutputDiff(base64_decode($outputDiff))
Expand Down
8 changes: 7 additions & 1 deletion webapp/src/Service/DOMJudgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1649,13 +1649,19 @@ private function actuallyCreateJudgetasks(int $priority, Judging $judging, int $

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

// Step 3: Insert the corresponding judging runs.
// Step 3: Insert the corresponding judging runs and output.
$this->em->getConnection()->executeQuery(
'INSERT INTO judging_run (judgingid, judgetaskid, testcaseid)
SELECT :judgingid, judgetaskid, testcase_id FROM judgetask
WHERE jobid = :judgingid ORDER BY judgetaskid',
['judgingid' => $judging->getJudgingid()]
);

$this->em->getConnection()->executeQuery(
'INSERT INTO judging_run_output (runid)
SELECT runid FROM judging_run WHERE judgingid = :judgingid',
['judgingid' => $judging->getJudgingid()]
);
}

public function shadowMode(): bool
Expand Down

0 comments on commit beeb7b3

Please sign in to comment.