Skip to content

Commit 116e9cf

Browse files
meisterTnickygerritsen
authored andcommitted
Indicate to the judgehost to retry if we are cleaning up old queue tasks.
Related: 80c1a43 (cherry picked from commit 780c7c9)
1 parent 9b03ea1 commit 116e9cf

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

judge/judgedaemon.main.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function read_credentials(): void
6060
"waiting" => false,
6161
"errorred" => false,
6262
"last_attempt" => -1,
63+
"retrying" => false,
6364
];
6465
}
6566
if (count($endpoints) <= 0) {
@@ -780,8 +781,19 @@ function fetch_executable_internal(
780781

781782
// We have gotten a work packet.
782783
$endpoints[$endpointID]["waiting"] = false;
784+
783785
// All tasks are guaranteed to be of the same type.
784786
$type = $row[0]['type'];
787+
788+
if ($type == 'try_again') {
789+
if (!$endpoints[$endpointID]['retrying']) {
790+
logmsg(LOG_INFO, "API indicated to retry fetching work (this might take a while to clean up).");
791+
}
792+
$endpoints[$endpointID]['retrying'] = true;
793+
continue;
794+
}
795+
$endpoints[$endpointID]['retrying'] = false;
796+
785797
logmsg(LOG_INFO,
786798
"⇝ Received " . sizeof($row) . " '" . $type . "' judge tasks (endpoint $endpointID)");
787799

webapp/src/Controller/API/JudgehostController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,16 @@ public function getJudgeTasksAction(Request $request): array
15941594
->setMaxResults(1)
15951595
->getQuery()
15961596
->getOneOrNullResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);
1597+
if ($jobid === null) {
1598+
return;
1599+
}
15971600
$judgetasks = $this->getJudgetasks($jobid, $max_batchsize, $judgehost);
1598-
if ($judgetasks !== null) {
1601+
if (empty($judgetasks)) {
1602+
// Somehow we got ourselves in a situation that there was a queue task without remaining judge tasks.
1603+
// This should not happen, but if it does, we need to clean up. Each of the fetch-work calls will clean
1604+
// up one queue task. We need to signal to the judgehost that there might be more work to do.
1605+
$judgetasks = [['type' => 'try_again']];
1606+
} else {
15991607
// Mark it as being worked on.
16001608
$this->em->createQueryBuilder()
16011609
->update(QueueTask::class, 'qt')

0 commit comments

Comments
 (0)