fix: a snapshot of a shared store handle is not tied to the user that took it

未关闭
#283 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
go
领域
databases

调研方向

Start in internal/graphstore/shared.go, where one Pebble handle is shared per store path, then read Snapshot() and Close() in internal/graphstore/pebble_store.go around lines 331, 354 and 489. Settle the open choice between per-user reader counting and the rule in design.md D1 that each user closes its readers first, using review note inv-1 in openspec/changes/archive/2026-11-11-shared-store-handle/review.md. Done means a two-user test through graphstore.Open where the non-final Close reports its own open snapshot.

由索引模型根据 Issue 内容生成。

描述

bug priority:low
What happens

graphstore shares one Pebble handle for each store path in a process (internal/graphstore/shared.go). Snapshot() returns a pebbleReader that holds only its Pebble snapshot (internal/graphstore/pebble_store.go:331). The reader has no link to the store that created it.

pebbleReader.Close releases its snapshot (pebble_store.go:489). pebbleStore.Close returns nil while other users still hold the handle (pebble_store.go:354). A snapshot that one user leaks stays open until the last user closes the handle. Pebble then reports the leak on that last user's Close, not on the user that leaked it.

Review note inv-1 in openspec/changes/archive/2026-11-11-shared-store-handle/review.md records this. Every production caller closes its snapshot first today, so this is a latent defect, not a present one.

What you expected instead

The leak error must land on the user that took the snapshot. A Close that is not the last one must report its own open readers.

Whether the store counts open readers per user, or D1 in design.md states that each user closes its readers first, is open. Either choice needs a test with two users, where one closes with an open snapshot.

Steps to reproduce

Found by code reading. No test in the tree covers this case.

  1. Open one store path twice in one process with graphstore.Open. Name the handles first and second.
  2. Call first.Snapshot() and keep the reader open.
  3. Call first.Close(). It returns nil.
  4. Call second.Close(). Pebble reports the open snapshot here.
Version

Not from a release build. Found on main at c6788f5d, after #282 merged.

Platform

Darwin 27.2.0 (macOS). The architecture was not recorded.

How did you install it?

Other

Found in review of #282, not from an install.

Languages in the affected repository

Not applicable. The defect is in the Go store, not in language extraction.

Before submitting
  • I searched existing issues and this is not a duplicate
  • I checked the capability matrix and this is not a documented limitation
  • This is not a security vulnerability

Related: #282 added the shared handle, and review note inv-1 names this defect.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ATb3AjCdy2v381oRkeyVrV

主要语言
Go
星标
0
派生
0
平均合并
7 小时 42 分钟
30 天内合并 PR
111

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

seanb4t/codegraph-go 的其他 Issue

查看 seanb4t/codegraph-go 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。