Skip to content

Commit 780c7c9

Browse files
committed
Indicate to the judgehost to retry if we are cleaning up old queue tasks.
Related: 80c1a43
1 parent f31b539 commit 780c7c9

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) {
@@ -785,8 +786,19 @@ function fetch_executable_internal(
785786

786787
// We have gotten a work packet.
787788
$endpoints[$endpointID]["waiting"] = false;
789+
788790
// All tasks are guaranteed to be of the same type.
789791
$type = $row[0]['type'];
792+
793+
if ($type == 'try_again') {
794+
if (!$endpoints[$endpointID]['retrying']) {
795+
logmsg(LOG_INFO, "API indicated to retry fetching work (this might take a while to clean up).");
796+
}
797+
$endpoints[$endpointID]['retrying'] = true;
798+
continue;
799+
}
800+
$endpoints[$endpointID]['retrying'] = false;
801+
790802
logmsg(LOG_INFO,
791803
"⇝ Received " . sizeof($row) . " '" . $type . "' judge tasks (endpoint $endpointID)");
792804

webapp/src/Controller/API/JudgehostController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,8 +1611,16 @@ public function getJudgeTasksAction(Request $request): array
16111611
->setMaxResults(1)
16121612
->getQuery()
16131613
->getOneOrNullResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);
1614+
if ($jobid === null) {
1615+
return;
1616+
}
16141617
$judgetasks = $this->getJudgetasks($jobid, $max_batchsize, $judgehost);
1615-
if ($judgetasks !== null) {
1618+
if (empty($judgetasks)) {
1619+
// Somehow we got ourselves in a situation that there was a queue task without remaining judge tasks.
1620+
// This should not happen, but if it does, we need to clean up. Each of the fetch-work calls will clean
1621+
// up one queue task. We need to signal to the judgehost that there might be more work to do.
1622+
$judgetasks = [['type' => 'try_again']];
1623+
} else {
16161624
// Mark it as being worked on.
16171625
$this->em->createQueryBuilder()
16181626
->update(QueueTask::class, 'qt')

0 commit comments

Comments
 (0)