fix: avoid stale task recovery on read pods
This commit is contained in:
@@ -2890,10 +2890,18 @@ async function sleepForRetryBackoff(task: QueueTask, delayMs: number): Promise<v
|
||||
}
|
||||
}
|
||||
|
||||
function queueActiveTasksForRestartRetry(reason: string, method: string): number {
|
||||
function taskHasLocalExecutionRecoveryClaim(task: QueueTask): boolean {
|
||||
if (task.status === "judging") return true;
|
||||
if (activeRunForTask(task) !== null) return true;
|
||||
return activeRunSlotReservations.has(queueIdOf(task));
|
||||
}
|
||||
|
||||
function queueActiveTasksForRestartRetry(reason: string, method: string, options: { onlyActiveRuns?: boolean } = {}): number {
|
||||
if (!config.schedulerEnabled || !serviceRoleAllowsScheduler(config.serviceRole)) return 0;
|
||||
let recovered = 0;
|
||||
for (const task of state.tasks) {
|
||||
if (task.status !== "running" && task.status !== "judging") continue;
|
||||
if (options.onlyActiveRuns === true && !taskHasLocalExecutionRecoveryClaim(task)) continue;
|
||||
task.status = "retry_wait";
|
||||
task.finishedAt = null;
|
||||
task.readAt = null;
|
||||
@@ -3443,7 +3451,7 @@ function installShutdownHandlers(): void {
|
||||
const stop = (signal: NodeJS.Signals): void => {
|
||||
if (shutdownRequested) process.exit(0);
|
||||
shutdownRequested = true;
|
||||
const recovered = queueActiveTasksForRestartRetry("Service stopping while task was active", "shutdown");
|
||||
const recovered = queueActiveTasksForRestartRetry("Service stopping while task was active", "shutdown", { onlyActiveRuns: true });
|
||||
for (const run of activeRuns.values()) run.app.stop();
|
||||
activeRuns.clear();
|
||||
activeRunSlotReservations.clear();
|
||||
|
||||
Reference in New Issue
Block a user