Repository navigation
fix(durable): 入口预检把残留的 shadow 信封当作无 canonical 会话 - #3028
Merged
Merged
Conversation
shadow 切 primary 后同 key 残留的 shadow 行让 readPrimarySession / authorizeBeforeAck / pendingCardBeforeAck / resolve 直接抛 invalid envelope,消息在 admission 前就卡住。新增 canonicalPrimarySession,非 primary 信封按无 canonical 会话处理,与 admission 对同一行的判断一致。
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 11:11
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
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.
Fixes #1861
只处理 issue 里的第 ③ 项(残留 shadow 信封让入口预检抛错)。① 前缀 claim 索引、② consumer 重试上限、④ generation 门禁用例属于性能/新增机制/测试加固,不在本 PR 范围。
症状
coordination store 从 shadow 受控切到 primary 后,旧 anchor 的 canonical key 上可能还留着
botmux.session.shadow行。此时:assertPrimaryRouteOwner在 admission 之前就抛invalid envelope,每次重试都一样,这条话题的消息进不了 admission;根因
这些入口直接对 canonical 行调用
parseDurablePrimarySessionRecord,它对非botmux.session.primary信封一律 throw。而 admission 自己(mergePrimaryProjection)本来就把 shadow 行当作「没有 primary 快照」并覆盖它,入口和 admission 对同一行的判断不一致。修法
durable-session-primary.ts新增canonicalPrimarySession(record):行不存在或信封不是 primary 时返回undefined;是 primary 但格式坏了仍然 throw。readPrimarySession→ 返回undefined,assertPrimaryRouteOwner得到none,消息继续走 admission,由 admission 覆盖 shadow 行;authorizeBeforeAck→false;pendingCardBeforeAck→undefined;resolve→ 走既有的「canonical Session is unavailable」分支。验证
test/durable-lark-session-control-runtime.test.ts新增用例:用临时目录里的 SQLite coordination store,经 facade 写入一条真实的 shadow 投影。canonicalPrimarySession对它返回undefined,对坏掉的 primary 信封仍抛错;authorizeBeforeAck→false,pendingCardBeforeAck→undefined,resolve→ 「canonical Session is unavailable」;变异验证:换回 master 的 runtime 文件时该用例变红(
invalid envelope);去掉 helper 的信封类型判断时也变红。引用这三个模块的 9 个测试文件(临时 HOME 下运行)96 个用例全绿;
bun run build通过。