trustPackedRefsStat=after_open does not work reliably

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

@klingarkar がすでに取り組んでいます。

2026年6月15日 から。

評価

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

調査の方向性

Start with RefDirectory's AFTER_OPEN refresh path and FileSnapshot.isModified(), which the issue identifies as the decision point; review the reproduction steps using RepositoryCache and PackedBatchRefUpdate to understand the NFS scenario. Done means a reader configured with trustPackedRefsStat=after_open reliably notices packed-refs replacements and re-reads the refs; the issue names no test file, so first locate the relevant packed-refs refresh tests.

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

説明

Version

6.10

Operating System

Linux/Unix

Bug description

On an NFS-backed repository shared by multiple hosts, a reading host can fail to observe updates to packed-refs made by a writing host, even when core.trustPackedRefsStat=after_open is configured.

RefDirectory's AFTER_OPEN refresh opens the packed-refs file itself to force the NFS client to refresh cached attributes before FileSnapshot.isModified() decides whether to re-read it. This is insufficient in the following scenario:

On NFS, updating packed-refs replaces the file by atomically swapping in a new inode under the same name. If the previous packed-refs is still held open on a host when the swap occurs, NFS preserves the old inode as a hidden .nfsXXXX entry instead of deleting it (silly-rename). In this state, a reading host can keep resolving/observing the stale inode, and opening+closing the packed-refs file does not reliably trigger an attribute refresh. As a result, isModified() compares against stale attributes, concludes nothing changed, and the reader skips re-reading, so refs written on the writing host go unnoticed.

Actual behavior

With AFTER_OPEN configured, after a writing host updates packed-refs, a reading host may not detect that packed-refs was updated and read stale refs.

Expected behavior

After a writing host updates packed-refs, a reading host with AFTER_OPEN configured should always detect that packed-refs has changed and re-read it.

Relevant log output

Other information

This can possibly be reproduced by:

Reader

  1. Open a repo (with trustPackedRefsStat=after_open configured) via JGit RepositoryCache
  2. Start a reader thread which calls getRefDatabase().getRefs() in a loop
  3. Print any added/changed refs whenever a change in refs is detected

Writer

  1. Open the same repo's packed-refs file once in a thread and keep it open for the whole test run
  2. Repeat below for a few iterations:
  • Open the repo via RepositoryCache
  • Create a new commit
  • Generate couple of randomly named refs
  • Write both refs atomically using PackedBatchRefUpdate
  • Sleep 1-2s before the next iteration
  1. After all iterations, stop the packed-refs holder thread
主要言語
Java
スター
427
フォーク
116
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

eclipse-jgit/jgit のほかの issue

eclipse-jgit/jgit の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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