From d3a73c1407f8936cb45516da8d3a2d4dd43c6379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Ar=C3=A8s?= Date: Fri, 10 Apr 2015 09:08:07 -0400 Subject: [PATCH 1/2] Lower log level to warn for handled pack errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pack not found and pack corrupted/invalid are handled by the code (pack is removed from the list) so logging an error and the stacktrace is misleading because it implies that there is an action to take to fix the error. Lower the log level to warn and remove the stacktrace for those 2 types of errors and keep the error log statement for any other. Change-Id: I2400fe5fec07ac6d6c244b852cce615663774e6e Signed-off-by: Hugo Arès Signed-off-by: Matthias Sohn --- .../storage/file/ObjectDirectory.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index 687408e19..9001dc349 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -554,22 +554,31 @@ void selectObjectRepresentation(PackWriter packer, ObjectToPack otp, } private void handlePackError(IOException e, PackFile p) { - String tmpl; + String warnTmpl = null; if ((e instanceof CorruptObjectException) || (e instanceof PackInvalidException)) { - tmpl = JGitText.get().corruptPack; + warnTmpl = JGitText.get().corruptPack; // Assume the pack is corrupted, and remove it from the list. removePack(p); } else if (e instanceof FileNotFoundException) { - tmpl = JGitText.get().packWasDeleted; + warnTmpl = JGitText.get().packWasDeleted; removePack(p); + } + if (warnTmpl != null) { + if (LOG.isDebugEnabled()) { + LOG.debug(MessageFormat.format(warnTmpl, + p.getPackFile().getAbsolutePath()), e); + } else { + LOG.warn(MessageFormat.format(warnTmpl, + p.getPackFile().getAbsolutePath())); + } } else { - tmpl = JGitText.get().exceptionWhileReadingPack; // Don't remove the pack from the list, as the error may be // transient. + LOG.error(MessageFormat.format( + JGitText.get().exceptionWhileReadingPack, p.getPackFile() + .getAbsolutePath()), e); } - LOG.error(MessageFormat.format(tmpl, - p.getPackFile().getAbsolutePath()), e); } @Override From ae4b72d50e84f9af7978075d4919ad4d2b1d018a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Ar=C3=A8s?= Date: Tue, 7 Apr 2015 11:17:06 -0400 Subject: [PATCH 2/2] Remove pack from list when file handle is stale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This error happens on nfs file system when you try to read a file that was deleted or replaced. When the error happens because the file was deleted, removing it from the list is the proper way to handle the error, same use case as FileNotFoundException. When the error happens because the file was replaced, removing the file from the list will cause the file to be re-read so it will get the latest version of the file. Bug: 462868 Change-Id: I368af61a6cf73706601a3e4df4ef24f0aa0465c5 Signed-off-by: Hugo Arès --- .../resources/org/eclipse/jgit/internal/JGitText.properties | 1 + .../src/org/eclipse/jgit/internal/JGitText.java | 1 + .../eclipse/jgit/internal/storage/file/ObjectDirectory.java | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 10f5339ae..602861859 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -394,6 +394,7 @@ packfileCorruptionDetected=Packfile corruption detected: {0} packFileInvalid=Pack file invalid: {0} packfileIsTruncated=Packfile {0} is truncated. packfileIsTruncatedNoParam=Packfile is truncated. +packHandleIsStale=Pack file {0} handle is stale, removing it from pack list packHasUnresolvedDeltas=pack has unresolved deltas packingCancelledDuringObjectsWriting=Packing cancelled during objects writing packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index 2448bf896..3077e18c1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -453,6 +453,7 @@ public static JGitText get() { /***/ public String packFileInvalid; /***/ public String packfileIsTruncated; /***/ public String packfileIsTruncatedNoParam; + /***/ public String packHandleIsStale; /***/ public String packHasUnresolvedDeltas; /***/ public String packingCancelledDuringObjectsWriting; /***/ public String packObjectCountMismatch; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index 9001dc349..796109aee 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -114,6 +114,8 @@ public class ObjectDirectory extends FileObjectDatabase { /** Maximum number of candidates offered as resolutions of abbreviation. */ private static final int RESOLVE_ABBREV_LIMIT = 256; + private static final String STALE_FILE_HANDLE_MSG = "stale file handle"; //$NON-NLS-1$ + private final Config config; private final File objects; @@ -563,6 +565,10 @@ private void handlePackError(IOException e, PackFile p) { } else if (e instanceof FileNotFoundException) { warnTmpl = JGitText.get().packWasDeleted; removePack(p); + } else if (e.getMessage() != null + && e.getMessage().toLowerCase().contains(STALE_FILE_HANDLE_MSG)) { + warnTmpl = JGitText.get().packHandleIsStale; + removePack(p); } if (warnTmpl != null) { if (LOG.isDebugEnabled()) {