diff options
author | Dariusz Luksza <dariusz.luksza@gmail.com> | 2023-11-20 11:53:19 +0000 |
---|---|---|
committer | Dariusz Luksza <dariusz.luksza@gmail.com> | 2024-01-29 09:57:16 +0000 |
commit | 7476183589f4c255ea561be9dff0109fc8919e9f (patch) | |
tree | 565440c98e11c9f73bf787e14ad2f39a390a5e79 /org.eclipse.jgit | |
parent | ca54c517647957685aa3401e097871aaebf250e3 (diff) | |
download | jgit-7476183589f4c255ea561be9dff0109fc8919e9f.tar.gz jgit-7476183589f4c255ea561be9dff0109fc8919e9f.zip |
Improve handling of NFS stale handle errors
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)
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java index 29f936587d..d6c25b2587 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java @@ -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. |