Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(wiki-ingest): prevent retry exhaustion on concurrent lock conflict
toy0116edbcfa80ab34
diff --git a/internal/application/service/wiki_ingest.go b/internal/application/service/wiki_ingest.goindex ca78d2bed..258b82f3d 100644--- a/internal/application/service/wiki_ingest.go+++ b/internal/application/service/wiki_ingest.go@@ -222,7 +222,7 @@ func EnqueueWikiIngest(ctx context.Context, task interfaces.TaskEnqueuer, redisCt := asynq.NewTask(types.TypeWikiIngest, payloadBytes,asynq.Queue("low"),- asynq.MaxRetry(10), // Increased from 3 to 10 to ensure it can outlast the 5-minute active lock TTL+ asynq.MaxRetry(25), // 25 × 15 s ≈ 6 min window; outlasts even large KB batchesasynq.Timeout(60*time.Minute),asynq.ProcessIn(wikiIngestDelay),)@@ -262,7 +262,7 @@ func EnqueueWikiRetract(ctx context.Context, task interfaces.TaskEnqueuer, redispayloadBytes, _ := json.Marshal(ingestPayload)t := asynq.NewTask(types.TypeWikiIngest, payloadBytes,asynq.Queue("low"),- asynq.MaxRetry(10), // Increased from 3 to 10 to outlast the active lock TTL+ asynq.MaxRetry(25), // 25 × 15 s ≈ 6 min window; outlasts even large KB batchesasynq.Timeout(60*time.Minute),asynq.ProcessIn(5*time.Second), // Retract can trigger the batch quickly)@@ -379,7 +379,7 @@ func (s *wikiIngestService) requeueFailedOps(ctx context.Context, payload WikiInpayloadBytes, _ := json.Marshal(retryPayload)t := asynq.NewTask(types.TypeWikiIngest, payloadBytes,asynq.Queue("low"),- asynq.MaxRetry(10),+ asynq.MaxRetry(25), // match main enqueue budgetasynq.Timeout(60*time.Minute),asynq.ProcessIn(wikiIngestDelay),)diff --git a/internal/application/service/wiki_ingest_batch.go b/internal/application/service/wiki_ingest_batch.goindex 5a39bc9f7..0db76eaa3 100644--- a/internal/application/service/wiki_ingest_batch.go+++ b/internal/application/service/wiki_ingest_batch.go@@ -34,7 +34,7 @@ func (s *wikiIngestService) scheduleFollowUp(ctx context.Context, payload WikiInpayloadBytes, _ := json.Marshal(payload)t := asynq.NewTask(types.TypeWikiIngest, payloadBytes,asynq.Queue("low"),- asynq.MaxRetry(10), // Increased from 3 to 10 to outlast the active lock TTL+ asynq.MaxRetry(25), // match main enqueue budget; outlasts large KB batchesasynq.Timeout(60*time.Minute),asynq.ProcessIn(5*time.Second), // short delay — active flag will be released by then)@@ -117,6 +117,17 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Tasklogger.Warnf(ctx, "wiki ingest: redis SetNX failed: %v", err)} else if !acquired {exitStatus = "active_lock_conflict"+ // If the pending list is already empty, the active batch will process+ // everything — no need to retry. Returning nil avoids burning through the+ // retry budget on tasks that would be no-ops when they eventually acquire+ // the lock. If there are still pending ops, retry so we don't miss them+ // in case the active batch drained the list before we RPush'd.+ pendingKey := wikiPendingKeyPrefix + payload.KnowledgeBaseID+ if n, _ := s.redisClient.LLen(ctx, pendingKey).Result(); n == 0 {+ exitStatus = "active_lock_conflict_empty"+ logger.Infof(ctx, "wiki ingest: concurrent batch active for KB %s, pending list empty — skipping", payload.KnowledgeBaseID)+ return nil+ }logger.Infof(ctx, "wiki ingest: another batch active for KB %s, deferring to asynq retry", payload.KnowledgeBaseID)return ErrWikiIngestConcurrent}