trustPackedRefsStat=after_open does not work reliably

未关闭
#271 2 条评论 0 个 reaction 已指派 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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-jgit/jgit 的其他 Issue

查看 eclipse-jgit/jgit 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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