fix: ReplaceStore swaps the symlink, not the store, when the live store directory is a symlink

オープン
#364 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go
領域
backend

調査の方向性

Read internal/graphstore/locks.go around ReplaceStore and internal/indexer/fullindex.go at the production call site; compare how #339 resolves store paths for lock files. The issue leaves the path-resolution approach open, and reproduction still needs confirmation. Done means a full index through a symlink updates the target store and keeps the symlink, or returns a clear error.

索引モデルが issue の本文から書いたものです。

説明

area:indexer bug needs-triage
What happens

Not reproduced yet. This comes from reading the code while fixing #339.

ReplaceStore(staging, live) in internal/graphstore/locks.go works on live as the caller passes it. It takes the swap lock, then calls os.Lstat(live) at line 118 of commit 990b6499.

If live is a symlink to the store directory, Lstat reports the link itself. The code then locks live at line 126 and calls exchangeDirs(staging, live) at line 131, which wraps fsatomic.ExchangeDirs. The exchange swaps the link's directory entry with staging.

The link name then holds the new index, and staging holds the symlink. The real store behind the link keeps the old index, and the link is gone.

The only production caller is run in internal/indexer/fullindex.go at line 184. codegraph init runs that full index. The same function exists on main with the same shape.

What you expected instead

One store has one identity, whatever name opens it. A full index through a symlinked store path must replace the store the link points to and keep the link. Otherwise, it must refuse with a clear error.

Whether ReplaceStore resolves live through resolveStorePath, as the #339 fix does for the lock files, is an open question.

Steps to reproduce
  1. Create a store at real/store with a full index.
  2. Run ln -s real/store link.
  3. Run a full index with the store path set to link. The flag or setting for the store path is not confirmed yet.
  4. Run ls -l link, then see whether real/store holds the new index.
Version

Built from source at commit 990b6499 on branch fix/339-swap-lock-realpath. The same function exists on main.

Platform

macOS, Darwin 27.2.0

How did you install it?

Built from source

Languages in the affected repository

Not applicable. The bug is in store path handling, not in extraction.

Related

#339 moves the swap and writer lock files beside the resolved store path. #324 covers letter case, and #286 covers path spellings for serve.

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

🤖 Generated with Claude Code

https://claude.ai/code/session_0167DcyrN4PrZewitbjYLc9L

主要言語
Go
スター
0
フォーク
0
平均マージ
7時間 42分
マージ済み PR(30日)
111

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

seanb4t/codegraph-go のほかの issue

seanb4t/codegraph-go の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。