Repository navigation
fix(hub): 刚上线的节点立刻对别的节点可见(节点名单变化时清状态缓存) - #3845
Conversation
…status The 10 s get_all_status cache (#3415) also cached who exists. A node that had just come online was missing from every cached answer for up to 10 s, so a peer asked to hand a task to it looked it up, found nothing and did nothing. The cache is now dropped when a status report adds a session or moves it across the online/offline line; heartbeats and idle/working changes still reuse it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2aac7f3980
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // conversations), so only the dispatch-sized preview is stored here. | ||
| const sessionTask = task == null ? null : sessionTaskPreview(task); // board668-session-preview | ||
| // A node appearing, returning or leaving must be visible to the next get_all_status (all-status-cache.ts). | ||
| if (rosterChanged(db.get<{ status: string | null }>("SELECT status FROM sessions WHERE resume_id = ?1", resume_id)?.status, storedStatus)) invalidateAllStatusCache(); |
There was a problem hiding this comment.
Account for same-alias handovers before invalidating the cache
When the SDK and Grok CLI reporters alternate for the same node, this lookup returns no row on every handover because the following DELETE removed that reporter's previous resume ID. This is an explicitly supported flow in server/src/report-status-resume-id-handover.test.ts, and agent-node/src/cli.ts supplies the distinct sdk- and grok-cli- IDs. Consequently, ordinary reports repeatedly clear every network's cache even though no node appeared or crossed the online/offline boundary, undermining the cache's protection against expensive fleet-wide serialization. Read the prior status from the same-alias, same-network handover row when the resume-ID lookup misses, rather than treating every handover as a new node.
Useful? React with 👍 / 👎.
为什么
「更早就坏」卡 #5402 的 P1:
Node caller identity compat (Docker, agent-node .110 and .121)失败在timeout: 121-sends child task。日志里的差别只有一处:
第 2 轮的两个节点是 16:42:57 才注册的,缓存里没有它们。被要求「交给某节点」的节点查名单、查不到对象,就什么都不做。推断根因:#3415(2026-11-09)给
get_all_status加的 10 秒缓存把「有哪些节点」也一起缓存了。待本 PR 上的这套测试证实。对真实用户的影响:一个节点刚上线(或刚恢复在线)的 10 秒内,别的节点看不到它,这时转交给它的任务会被静默丢掉。
改动
all-status-cache.ts:新增invalidateAllStatusCache()和rosterChanged(prior, next)——只有「新出现 / 离线→在线 / 在线→离线」算名单变化。tools.ts的report_status:写入会话前按主键读一次原状态,名单变化就清缓存。心跳和 idle/working 切换照旧走缓存,perf(server): cache get_all_status for 10 s per read scope + filters (+ commhub-server 0.9.0-preview.278) #3415 要解决的那个性能问题不受影响(多一次主键点查)。验证
all-status-cache.test.ts新增 3 条,本地 6 条通过。Node caller identity compat:已打full-qa。🤖 Generated with Claude Code