Skip to content

Commit e8a4623

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

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

judge/judgedaemon.main.php

Lines changed: 12 additions & 2 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) {
@@ -784,13 +785,22 @@ function fetch_executable_internal(
784785

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

792-
$jobId = $row[0]['jobid'];
793-
794804
if ($type == 'prefetch') {
795805
if ($lastWorkdir !== null) {
796806
cleanup_judging($lastWorkdir);

webapp/src/Controller/API/JudgehostController.php

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

0 commit comments

Comments
 (0)