fix(dispatch): 孤儿任务恢复重投与 Edge hubTaskId 去重 - #2074
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
DeliciousBuding
added a commit
that referenced
this pull request
Aug 29, 2026
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
This was referenced Aug 29, 2026
DeliciousBuding
added a commit
that referenced
this pull request
Aug 30, 2026
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
Run struct 新增 HubTaskID 字段,runcontrol.Create 在 runCreationMu 锁内检查已有同 hubTaskID 的 run 并幂等返回,防止孤儿恢复重投时 Edge 创建重复 run。SQLite migration v5 添加 edge_runs.hub_task_id 列与部分索引。 Closes #2066 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
Migration 0069 添加 model_params JSONB 列;TriggerAgentTask 创建任务 时写入 modelParams,使孤儿恢复重投能重建完整 dispatch 上下文。 Closes #2066 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
新增 orphan recovery sweeper:定期扫描 status=queued 且无 delivery_outbox 行的过期任务,CAS claim 后通过现有 DispatchTask 路径重投。上下文从 trigger_message/agent_instance/model_params 重建。 新增 dispatch_orphan metrics(discovered/redelivered)。 L1 集成测试覆盖正向 claim、grace 窗口负向、有 outbox 行负向。 Closes #2066 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
force-pushed
the
fix/dispatch-orphan-recovery
branch
from
August 30, 2026 17:13
eea9f23 to
4addc90
Compare
DeliciousBuding
added a commit
that referenced
this pull request
Aug 31, 2026
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
added a commit
that referenced
this pull request
Aug 31, 2026
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
added a commit
that referenced
this pull request
Aug 31, 2026
* fix(db): team route-decision JSONB COUNT 执行计划优化(#2102 F14) Co-authored-by: Cursor <cursor@vectorcontrol.tech> * chore(db): 迁移改号 0069→0070 避让 #2074 同号迁移 Co-authored-by: Cursor <cursor@vectorcontrol.tech> --------- Co-authored-by: DeliciousBuding <DeliciousBuding@users.noreply.github.com> Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
added a commit
that referenced
this pull request
Aug 31, 2026
重启 dev 栈后现场抓到:master hub-server 在 "health check passed" 后 卡死,goroutine dump 显示主 goroutine 停在 startServer → StartOrphanRecoveryLoop 的 select 循环上—— 该 sweeper 自 #2074 起阻塞调用方(startServer 主路径), HTTP server 永远走不到 "server starting",:8080 无监听。 修复:sweeper 循环移入内部 goroutine(与 delivery retry/cleanup、 run-event retention 等兄弟循环一致),方法立即返回。 补回归测试 TestStartOrphanRecoveryLoopDoesNotBlockCaller(3s 超时)。 本地验证:dispatchsvc+app 包测试、go build、sleep-ratchet 全绿。 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding
added a commit
that referenced
this pull request
Aug 31, 2026
重启 dev 栈后现场抓到:master hub-server 在 "health check passed" 后 卡死,goroutine dump 显示主 goroutine 停在 startServer → StartOrphanRecoveryLoop 的 select 循环上—— 该 sweeper 自 #2074 起阻塞调用方(startServer 主路径), HTTP server 永远走不到 "server starting",:8080 无监听。 修复:sweeper 循环移入内部 goroutine(与 delivery retry/cleanup、 run-event retention 等兄弟循环一致),方法立即返回。 补回归测试 TestStartOrphanRecoveryLoopDoesNotBlockCaller(3s 超时)。 本地验证:dispatchsvc+app 包测试、go build、sleep-ratchet 全绿。 Co-authored-by: DeliciousBuding <DeliciousBuding@users.noreply.github.com> Co-authored-by: Cursor <cursor@vectorcontrol.tech>
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.
Summary
Closes #2066
Hub 在「任务入队」与「outbox 记录」之间存在崩溃窗口与信号量回退两条静默丢失通道。本 PR 实现孤儿任务恢复重投机制,确保每个入队任务都必然收敛——被投递或被显式处理,不再静默滞留。
Changes
Task 1: Edge hubTaskId 去重
go test ./internal/runcontrol/ -run TestCreateHubTaskIDDedup -v→ PASSTask 2: pending_agent_tasks 持久化 model_params
go test -short ./...→ ALL PASSTask 3: 孤儿恢复 sweeper
go test ./internal/service/dispatchsvc/ -run TestClaimOrphanedTasks -v→ 5/5 PASSTask 4: Metrics + Logging
Task 5: L1 集成测试(真 PG)
AGENTHUB_DB_PASSWORD=dev_password go test -tags integration ./tests/integration/ -run TestOrphanRecovery -v→ 3/3 PASSDesign Decisions