]> source.dussan.org Git - jgit.git/commitdiff
Improve handling of NFS stale handle errors 25/1176125/1
authorDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 20 Nov 2023 11:53:19 +0000 (11:53 +0000)
committerDariusz Luksza <dariusz.luksza@gmail.com>
Mon, 29 Jan 2024 09:57:16 +0000 (09:57 +0000)
Mark packfile as invalid when NFS stale handle error occurs.

This should fix broken fetch operations when the repo is located on the
NFS system and is GC'ed on a separate system (or process). Which may
result in the index, pack or bitmap file being removed when they are
accessed from the fetch operation.

Bug: 573770
Signed-off-by: Dariusz Luksza <dariusz.luksza@gmail.com>
Change-Id: I70217bfb93bf7421ea2c1d74cbe4f15c76d9c098
(cherry picked from commit c701c01b49d92993f1c3df0a0e26a2dd68b8cec1)

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java

index 29f936587d8289ad24e3aac1d9995839acbe391b..d6c25b25877058f0eb7f006996de2e81217744d1 100644 (file)
@@ -56,6 +56,7 @@ import org.eclipse.jgit.lib.AnyObjectId;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectLoader;
+import org.eclipse.jgit.util.FileUtils;
 import org.eclipse.jgit.util.LongList;
 import org.eclipse.jgit.util.NB;
 import org.eclipse.jgit.util.RawParseUtils;
@@ -665,7 +666,12 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
                        // exceptions signaling permanent problems with a pack
                        openFail(true, pe);
                        throw pe;
-               } catch (IOException | RuntimeException ge) {
+               } catch (IOException ioe) {
+                       // mark this packfile as invalid when NFS stale file handle error
+                       // occur
+                       openFail(FileUtils.isStaleFileHandleInCausalChain(ioe), ioe);
+                       throw ioe;
+               } catch (RuntimeException ge) {
                        // generic exceptions could be transient so we should not mark the
                        // pack invalid to avoid false MissingObjectExceptions
                        openFail(false, ge);
@@ -1134,6 +1140,14 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
                                // removed index, packfile or the bitmap
                                bitmapIdxFile = null;
                                return null;
+                       } catch (IOException e) {
+                               if (!FileUtils.isStaleFileHandleInCausalChain(e)) {
+                                       throw e;
+                               }
+                               // Ignore NFS stale handle exception the same way as
+                               // FileNotFoundException above.
+                               bitmapIdxFile = null;
+                               return null;
                        }
 
                        // At this point, idx() will have set packChecksum.