FileReftableDatabase: reads fail with "Stale file handle" on NFS when another host compacts the reftable stack
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 56/100
Línea de trabajo
Start with FileReftableStack.readTableNames() and reload(), then inspect FileReftableDatabase.refresh(), exactRef(), getRefs(String), and getRefsByPrefixWithExclusions(); FileUtils.isStaleFileHandle() is identified as an existing precedent. Run FileReftableTest and FileReftableStackTest, then exercise concurrent updates and reads on NFS. Done means stale handles are retried and reads complete without failures under the reported workload.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment
- JGit
v7.5.0.202512021534-r-31-g4e67a23061(bundled in Gerrit3.13.1-914-g1e79490315) - Same code on JGit
masteras of 2026-11-16 (FileReftableStack.reload()only retries onFileNotFoundException) - Repository in reftable format on AWS EFS (NFS v4.1), shared by three JVMs on different hosts: one writer (Gerrit primary) and two readers (Gerrit replicas)
reftable.autorefresh = true,core.trustTablesListStat = after_open
Problem
With reftable.autorefresh = true the readers pick up the writer's updates correctly. But under write load, some reads on the reader hosts fail with java.io.IOException: Stale file handle.
On NFS, a file that another client has deleted or replaced by rename shows up as ESTALE on the local client, not as FileNotFoundException. That happens to reftable files all the time:
- The writer replaces
reftable/tables.listby renaming a lock file over it on every update. - The writer's auto-compaction deletes tables that readers on other hosts still have open.
FileReftableStack.reload() only retries on FileNotFoundException. Reads through already-open ReftableReaders have no retry at all, so the IOException reaches the caller.
In a 10-minute test (4 concurrent writers on the primary, git ls-remote loops against each replica), 0.6–5% of the reads on the replicas failed. Each failure was an HTTP 500 for the client. The primary never saw the error.
Stack traces (from the reader hosts)
- Reading
tables.listduring the auto-refresh check (most common):
java.io.UncheckedIOException: java.io.IOException: Stale file handle
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.refresh(FileReftableDatabase.java:277)
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.autoRefresh(FileReftableDatabase.java:254)
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.getRefs(FileReftableDatabase.java:199)
at org.eclipse.jgit.lib.RefDatabase.getRefsByPrefix(RefDatabase.java:430)
...
at org.eclipse.jgit.transport.UploadPack.lsRefsV2(UploadPack.java:1129)
Caused by: java.io.IOException: Stale file handle
at org.eclipse.jgit.internal.storage.file.FileReftableStack.readTableNames(FileReftableStack.java:292)
at org.eclipse.jgit.internal.storage.file.FileReftableStack.isUpToDate(FileReftableStack.java:334)
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.refresh(FileReftableDatabase.java:...)
- Reading from a table that was compacted away after it was opened:
java.io.IOException: Stale file handle
at org.eclipse.jgit.internal.storage.io.BlockSource$2.read(BlockSource.java:89)
at org.eclipse.jgit.internal.storage.reftable.BlockReader.readBlockIntoBuf(BlockReader.java:263)
at org.eclipse.jgit.internal.storage.reftable.BlockReader.readBlock(BlockReader.java:257)
at org.eclipse.jgit.internal.storage.reftable.ReftableReader.readBlock(ReftableReader.java:431)
at org.eclipse.jgit.internal.storage.reftable.ReftableReader.allRefs(ReftableReader.java:142)
at org.eclipse.jgit.internal.storage.reftable.MergedReftable.allRefs(MergedReftable.java:106)
at org.eclipse.jgit.internal.storage.reftable.ReftableDatabase.getRefsByPrefix(ReftableDatabase.java:266)
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.getRefs(FileReftableDatabase.java:200)
- Same, during the reload itself (rare):
java.io.IOException: Stale file handle
at org.eclipse.jgit.internal.storage.reftable.ReftableReader.readFileHeader(ReftableReader.java:281)
at org.eclipse.jgit.internal.storage.reftable.ReftableReader.maxUpdateIndex(ReftableReader.java:125)
at org.eclipse.jgit.internal.storage.file.FileReftableStack.nextUpdateIndex(FileReftableStack.java:366)
at org.eclipse.jgit.internal.storage.file.FileReftableStack.reload(FileReftableStack.java:251)
at org.eclipse.jgit.internal.storage.file.FileReftableDatabase.refresh(FileReftableDatabase.java:271)
Steps to reproduce
- Put a bare repository in reftable format on NFS and open it from two hosts with
reftable.autorefresh = true. - On host A, update refs continuously (each update adds a table and auto-compacts).
- On host B, list refs in a loop (
getRefsByPrefix,exactRef, orgit ls-remotevia a JGit server). - Host B intermittently gets
IOException: Stale file handle.
Proposed fix
Treat ESTALE like a missing file. FileUtils.isStaleFileHandle() and isStaleFileHandleInCausalChain() already exist and are used for pack files.
FileReftableStack.readTableNames(): retry a few times on a stale file handle.FileReftableStack.reload(): on a stale file handle, retry with every table opened again instead of reusing the open readers. IncludenextUpdateIndex()in the retried block. IgnoreESTALEwhen closing the old readers.FileReftableDatabase.exactRef(),getRefs(String),getRefsByPrefixWithExclusions(): if the read fails with a stale file handle, reload the stack with all tables reopened (under the database lock) and retry a few times.
I have a patch against 4e67a23061 (~200 lines in FileReftableStack and FileReftableDatabase) and can push it to GerritHub for review.
Results with the patch
Same 10-minute load test, patched JGit on all three hosts:
Stale file handlein the readers' logs: 0 (before: 63 and 269 in two runs)- HTTP 5xx on any host: 0 (~7,900 reads on the replicas, ~1,200 writes on the primary)
- All three hosts reported identical refs afterwards
FileReftableTestandFileReftableStackTest: 41/41 pass, both before and after the patch
- Lenguaje dominante
- Java
- Estrellas
- 427
- Forks
- 116
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de eclipse-jgit/jgit
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
eclipse-jgit/jgit#329 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
eclipse-jgit/jgit#327 ·
-
Repository.create(boolean bare) should provide a no-arg overload that uses isBare()Quizá libre de nuevo @hardikyadav12 la tomó hace 77 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
eclipse-jgit/jgit#297 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
eclipse-jgit/jgit#293 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
eclipse-jgit/jgit#288 ·
Todos los issues de eclipse-jgit/jgit
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
constellation-app/constellation#2613 ·
Los mantenedores suelen responder en 2 días
-
[JUKEBOW] Arrows can be stolenAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Vakore/ZappierGames#334 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
IETF-Hackathon/pqc-certificates#369 ·
Los mantenedores suelen responder en 1 día
-
? - Needs Triage bot_watch bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA/cudf-spark-jni#5594 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100