fix(jobs): claim only handled kinds and requeue numbered workers after a crash

An engine with no handlers (or a filter it could not serve) claimed every
job, so a host without a render handler would fail render-node work.
With several workers, jobs carry node ids such as pc#1, but crash
recovery only matched the bare node id and left them running forever.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 12:49:15 +00:00
1 parent b4f61e29b9
commit 6ac27413a7
3 files changed
+52 -5

No files matched your search

@@ -108,13 +108,14 @@ public sealed class JobRepository
/// <summary>
/// Crash recovery: puts running jobs back in the queue, keeping their checkpoints. With <paramref name="nodeId"/>
/// only that worker's jobs are requeued (other server instances keep theirs).
/// only that node's jobs are requeued, including those of its numbered workers (<c>node#0</c>, <c>node#1</c>, …);
/// other server instances keep theirs.
/// </summary>
public Task<int> RequeueRunningAsync(string? nodeId = null, CancellationToken cancellationToken = default) =>
_db.ExecuteAsync(
$"UPDATE jobs SET state = {(int)JobState.Queued}, node_id = NULL, started = NULL WHERE state = {(int)JobState.Running}" +
(nodeId is null ? string.Empty : " AND node_id = $1"),
nodeId is null ? [] : [nodeId], cancellationToken);
(nodeId is null ? string.Empty : " AND (node_id = $1 OR substr(node_id, 1, length($2)) = $2)"),
nodeId is null ? [] : [nodeId, nodeId + "#"], cancellationToken);
private static Job Map(DbRow r) => new()
{