fix(summary): mark refresh failed on terminal delivery - #37
Draft
lyingbug wants to merge 2 commits into
Draft
Conversation
PR Tencent#2505 replaced the unconditional summary_status=failed write in the refresh branch with a bare error return so asynq could retry. Several RegenerateKnowledgeSummary failure paths never persist a status of their own (tenant lookup, KB lookup, unconfigured summary model, chunk listing, freshness verification), so once the retry budget was spent the row stayed in pending/processing and the frontend kept rendering "generating summary" forever. Route refresh failures through handleSummaryRefreshFailure, which keeps the retry semantics for non-terminal deliveries and writes failed on the last attempt. Stale and insufficient-content outcomes stay swallowed. Co-authored-by: lyingbug <lyingbug@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
本分支基于 Tencent/WeKnora#2505 的 head,在其之上修复一个由该 PR 引入的状态卡死回归。若 Tencent#2505 尚未合并,建议将本次修复直接并入 Tencent#2505。
问题
Tencent#2505 将摘要刷新分支中无条件的
summary_status = failed写入:改成了裸的
return err,以便让 Asynq 的MaxRetry(3)生效。这个方向是对的,但RegenerateKnowledgeSummary有多条失败路径不会自己写任何状态:restoreSummaryRefreshTenantInfo租户查询失败GetKnowledgeByID/GetKnowledgeBaseByID读取失败kb.SummaryModelID == ""(排队期间 KB 配置被改)ListChunksByKnowledgeID读取失败processing的UpdateKnowledge失败summarySourceChanged返回查询错误enqueueSummaryRefresh在入队前已把状态写为pending,RegenerateKnowledgeSummary随后写processing。上述任一路径连续失败 4 次后,状态永久停留在pending或processing。前端把这两个状态都渲染为"正在生成摘要"的 loading 态(
DocumentListView.vue、DocumentCardView.vue、doc-content.vue中的isSummaryStatusInFlight),因此文档会无限显示"正在生成摘要",且doc-content.vue会持续轮询。修改
新增
handleSummaryRefreshFailure,集中处理刷新失败的语义:applyRetryableSummaryFailureState已负责写pending)。summary_status = failed后再返回错误。使用UpdateKnowledgeColumn而非整行写入,避免覆盖RegenerateKnowledgeSummary可能刚发布的首 chunk 兜底description。ErrSummaryRefreshStale:仍然吞掉并返回nil——更新的刷新任务拥有状态所有权。errInsufficientSummaryContent:仍然吞掉——调用方已写入failed。状态写入失败只记 warning,不掩盖原始生成错误。
Type of Change
Related Issue
修复 Tencent/WeKnora#2505 引入的回归。
Checklist
go vet与受影响包的测试全部通过(internal/application/service、internal/router、internal/types、internal/handler、internal/middleware/...)新增
TestHandleSummaryRefreshFailure,覆盖:可重试投递不写状态、终端投递写failed、包装后的错误仍能识别终端、stale 不写状态、insufficient-content 不额外写入、状态写入失败不掩盖原始错误。