memory: two processes clearing one crash-left lock guard can remove a live guard
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 42/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
Start with isGuardHeld in src/memory/index.ts and the existing lock tests; trace how stale guards are judged and removed by path. The approach is undecided, so first compare it with breakStaleLock and define the remaining race before choosing a fix. Done means a deterministic test shows a fresh guard survives when two processes clear the same crash-left guard, and the existing lock tests pass.
由索引模型根据 Issue 内容生成。
描述
Problem
The memory server's cross-process lock uses a second exclusive-create file, the guard (<memory file>.lock.break), to order stale-lock breaking and, since #5565 (PR #5623), every release and every newly created lock's confirmation. A guard left behind by a process that crashed while holding it is cleared by whoever finds it older than the stale timeout (30 seconds by default).
That clearing is done by path: the finder opens the guard, judges its age through the handle, and then calls unlink on the guard's path (isGuardHeld in src/memory/index.ts; before #5565 the same stat then unlink in breakStaleLock). Two processes clearing the same crash-left guard at once can therefore remove a live one:
- A and B both open the crash-left guard and judge it stale.
- A unlinks it.
- C (a releasing holder, or a breaker) creates a fresh guard at the same path.
- B unlinks the path, deleting C's fresh guard.
C then runs its few guarded file-system calls unguarded, so a breaker can act between a release's token comparison and its removal (the third window of #5565), or two breakers can run at once.
It takes a crash inside a guarded section (a few file-system calls per write), then two processes clearing that guard within the same moment, then a third taking the guard between their two unlinks. The processes run as the same user, so this is a correctness gap, not a security boundary. Raised by Copilot in review of #5623 and declined there as beyond the three windows #5565 names.
Expected behavior
Clearing a guard left by a crash never removes a guard another process has taken since.
Approach
To be decided. Renaming the guard aside and comparing device and inode with the judged file before deleting it, as breakStaleLock does for the lock itself (#5560), removes exactly this interleaving, but putting a mistakenly taken live guard back has its own gap one level down (a create at the guard path while it is aside). Whatever is chosen should say what remains, as the comment above guardPathOf() does today.
Acceptance criteria
- A deterministic test (no timing dependence): two clearers of one crash-left guard, with a fresh guard created between their removals; the fresh guard survives.
- The existing lock tests still pass.
- 主要语言
- TypeScript
- 星标
- 92k
- 派生
- 12k
- 平均合并
- 3 小时 46 分钟
- 30 天内合并 PR
- 206
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/servers 的其他 Issue
-
`interface-diff` discards the git error when resolving its default base and reports the wrong cause未关闭
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/servers#5636 ·
维护者通常 1 天内回复
-
chore server-memory v2
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/servers#5634 ·
维护者通常 1 天内回复
-
documentation server-memory v2
难度 1/5 1 小时以内 新手友好度 90/100
modelcontextprotocol/servers#5609 · 1 条评论 ·
维护者通常 1 天内回复
-
bug server-memory v2
难度 4/5 3-5 天 新手友好度 48/100
modelcontextprotocol/servers#5635 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement v2
难度 4/5 3-5 天 新手友好度 48/100
modelcontextprotocol/servers#5611 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/servers 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 79/100
hurttlocker/o8#6535 ·
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
area: backend bug priority: low
难度 2/5 1-3 小时 新手友好度 92/100
snapotter-hq/SnapOtter#4856 ·
维护者通常 1 天内回复
-
bug follow-up
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
spellshift/realm#2509 ·
维护者通常 1 天内回复