Skip to content

Commit

Permalink
Indicate to the judgehost to retry if we are cleaning up old queue ta…
Browse files Browse the repository at this point in the history
…sks.

Related: DOMjudge@80c1a43
  • Loading branch information
meisterT committed Nov 23, 2024
1 parent f31b539 commit 780c7c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function read_credentials(): void
"waiting" => false,
"errorred" => false,
"last_attempt" => -1,
"retrying" => false,
];
}
if (count($endpoints) <= 0) {
Expand Down Expand Up @@ -785,8 +786,19 @@ function fetch_executable_internal(

// We have gotten a work packet.
$endpoints[$endpointID]["waiting"] = false;

// All tasks are guaranteed to be of the same type.
$type = $row[0]['type'];

if ($type == 'try_again') {
if (!$endpoints[$endpointID]['retrying']) {
logmsg(LOG_INFO, "API indicated to retry fetching work (this might take a while to clean up).");
}
$endpoints[$endpointID]['retrying'] = true;
continue;
}
$endpoints[$endpointID]['retrying'] = false;

logmsg(LOG_INFO,
"⇝ Received " . sizeof($row) . " '" . $type . "' judge tasks (endpoint $endpointID)");

Expand Down
10 changes: 9 additions & 1 deletion webapp/src/Controller/API/JudgehostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,16 @@ public function getJudgeTasksAction(Request $request): array
->setMaxResults(1)
->getQuery()
->getOneOrNullResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);
if ($jobid === null) {
return;
}
$judgetasks = $this->getJudgetasks($jobid, $max_batchsize, $judgehost);
if ($judgetasks !== null) {
if (empty($judgetasks)) {
// Somehow we got ourselves in a situation that there was a queue task without remaining judge tasks.
// This should not happen, but if it does, we need to clean up. Each of the fetch-work calls will clean
// up one queue task. We need to signal to the judgehost that there might be more work to do.
$judgetasks = [['type' => 'try_again']];
} else {
// Mark it as being worked on.
$this->em->createQueryBuilder()
->update(QueueTask::class, 'qt')
Expand Down

0 comments on commit 780c7c9

Please sign in to comment.