The stuck-row sweep asks the asynq inspector whether a candidate still has
work queued, and treats "nothing queued" as proof the row is orphaned. For
Wiki that question cannot be answered by asynq at all:
- Wiki ingest work is durable per document in task_pending_ops, keyed by
dedup_key = knowledge ID (newWikiIngestPendingOp).
- asynq only receives a per-KB wake-up trigger, whose payload carries
KnowledgeBaseID and no knowledge ID (enqueueWikiIngestTrigger).
- matchesKnowledge() gates on taskTypesForKnowledgeCancel, which
deliberately excludes TypeWikiIngest.
So HasQueuedTasksForKnowledge structurally returns false for a document
whose only outstanding work is a queued Wiki ingest. The sweep then flips a
perfectly healthy 'finalizing' row to 'failed' with "task stuck in
processing", zeroes pending_subtasks_count, and the durable op later runs
anyway — which is how a document ends up failed while present in neither the
dead-letter table nor any visible queue.
Probe task_pending_ops directly before consulting the inspector. A durable
probe error defers every candidate to the next sweep instead of failing them:
wrongly failing a live document is not user-recoverable, waiting one interval
is. The inspector's own fail-safe direction is unchanged.
A nil inspector no longer disables the whole gate, only the transient half.
TestHousekeeping_NoFalseKill_DurableWikiIngestPending reproduces the bug (it
fails on the unpatched sweep); TestHousekeeping_StillRecoversWhenNoDurableOp
guards against the gate becoming a blanket amnesty.