feat(knowledge): count wiki ingest in the finalizing subtask counter
Wiki ingest runs asynchronously after the parse pipeline and was not counted in pending_subtasks_count, so a document flipped to "completed" while wiki generation was still minutes away (30s debounce + batch + retries). That hid the in-progress state and dropped the stop-parse affordance before wiki actually finished. Count wiki as a single enrichment subtask (when WikiEnabled and the doc has text chunks, matching the enqueue condition) so the row stays in "finalizing" until wiki is done. The batch worker drains the slot at the op's terminal state: once on successful map, and once when an op is dead-lettered after exhausting in-batch retries. Retract ops (deleted knowledge) are skipped. FinalizeSubtask guards both the decrement and the promote, so a wiki op enqueued before this accounting shipped is a harmless no-op on an already-completed row. A wiki op that never drains is bounded by the existing housekeeping finalizing sweep.
This commit is contained in:
@@ -667,7 +667,17 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Task
|
||||
// failed).
|
||||
failedAdditionSlugCount := len(failedAdditionSlugs)
|
||||
for _, r := range docResults {
|
||||
if r == nil || r.WikiSpan == nil {
|
||||
if r == nil {
|
||||
continue
|
||||
}
|
||||
// A successfully-mapped doc is terminal for its wiki op, so
|
||||
// release the knowledge's slot in pending_subtasks_count (the row
|
||||
// promotes to completed once the counter hits zero). Done before
|
||||
// the WikiSpan nil-check below so a doc that had no attempt to
|
||||
// attach a span to still drains its counter slot. The matching +1
|
||||
// is seeded by KnowledgePostProcess.SetFinalizing.
|
||||
s.finalizeWikiSubtask(ctx, r.KnowledgeID)
|
||||
if r.WikiSpan == nil {
|
||||
continue
|
||||
}
|
||||
writtenPages := make([]map[string]string, 0, len(r.Pages))
|
||||
|
||||
Reference in New Issue
Block a user