fix(knowledge): drain finalizing counter on all terminal subtask exits
The finalizing subtask counter (introduced when wiki ingest was counted) could leak slots, leaving a fully-parsed doc stuck in "finalizing" until the housekeeping sweep wrongly marked it "failed". - wiki ingest: a doc skipped in map (knowledge deleted / no chunks / insufficient text) produced no docResult and was not a failedOp, so neither the success nor the dead-letter drain fired. Drain the slot on that terminal skip path. - summary & question: the drain was keyed on the span-error variable, which assumes "err != nil => asynq will retry". Several branches set that variable yet `return nil` (insufficient text content, KB/knowledge fetch failures) - terminal, no retry - so the drain was skipped. Key the drain on the value actually returned to asynq (named retErr) instead, so terminal nil-returns drain and only retried errors wait for the final attempt. Also fix the trace panel header flashing "已完成" mid-wiki: the latest attempt's root span closes while async post-pipeline subspans keep running, so trace.status read terminal while the row was still "finalizing". Prefer parse_status on the latest attempt while it is non-terminal so the panel header, LIVE badge and doc card agree, and add the "finalizing" status label to all locales.
This commit is contained in:
@@ -464,6 +464,21 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Task
|
||||
// scrub. Compare with the legacy Redis path, which kept
|
||||
// a separate wiki:failcount:<...> key alive for 24h
|
||||
// regardless of whether the original op had drained.
|
||||
//
|
||||
// The finalizing slot is drained later (after reduce +
|
||||
// publish) in the docResults loop, so "completed" only
|
||||
// arrives once wiki is fully written.
|
||||
} else {
|
||||
// err == nil && result == nil: mapOneDocument skipped this
|
||||
// doc at a terminal, non-retryable state (knowledge
|
||||
// deleted / no chunks / insufficient text). It produces no
|
||||
// docResult and is not a failedOp, so neither the success
|
||||
// nor the dead-letter drain path will fire. Release the
|
||||
// finalizing slot here so the row doesn't hang in
|
||||
// "finalizing" until the housekeeping sweep marks it
|
||||
// failed. The matching +1 was seeded by
|
||||
// KnowledgePostProcess.SetFinalizing.
|
||||
s.finalizeWikiSubtask(mapCtx, op.KnowledgeID)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user