From 37818f0faac0276a219125e6b098af225c5bc723 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 18 Feb 2025 11:12:08 +0100 Subject: [PATCH 1/3] improve logging for isStrictlyNewerThanDocument() --- .../java/org/opengrok/indexer/index/IndexDatabase.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java index 2c85ca2a340..30ee6457f5d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java @@ -893,6 +893,7 @@ private static boolean isStrictlyNewerThanDocument(File file) { try { Document doc = IndexDatabase.getDocument(file); if (Objects.isNull(doc)) { + LOGGER.log(Level.WARNING, "cannot get document for ''{0}''", file); return true; } IndexableField field = doc.getField(QueryBuilder.DATE); @@ -900,14 +901,19 @@ private static boolean isStrictlyNewerThanDocument(File file) { Date docDate = DateTools.stringToDate(field.stringValue()); // Assumes millisecond precision. long lastModified = file.lastModified(); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINEST, String.format("checking date for '%s': %d %d", + file, lastModified, docDate.getTime())); + } if (lastModified <= docDate.getTime()) { return false; } } catch (java.text.ParseException e) { + LOGGER.log(Level.WARNING, String.format("cannot convert date for '%s'", file), e); return true; } } catch (ParseException | IOException e) { - LOGGER.log(Level.FINEST, "cannot get document for ''{0}''", file); + LOGGER.log(Level.WARNING, String.format("cannot get document for '%s'", file), e); } return true; From 2b0050eb025046bc84a37aa0b098e9ddd5ff64c9 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 18 Feb 2025 13:13:53 +0100 Subject: [PATCH 2/3] improve the logging in getDocument() --- .../main/java/org/opengrok/indexer/index/IndexDatabase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java index 30ee6457f5d..0ccefb4f940 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java @@ -2111,7 +2111,8 @@ public static Document getDocument(File file) throws ParseException, IOException try { Statistics stat = new Statistics(); TopDocs top = searcher.search(q, 1); - stat.report(LOGGER, Level.FINEST, String.format("search via getDocument(%s) done", file), + stat.report(LOGGER, Level.FINEST, + String.format("search via getDocument(%s) done (%d hits)", file, top.totalHits.value), "search.latency", new String[]{"category", "getdocument", "outcome", top.totalHits.value == 0 ? "empty" : "success"}); if (top.totalHits.value == 0) { @@ -2123,6 +2124,7 @@ public static Document getDocument(File file) throws ParseException, IOException // Only use the document if we found an exact match. if (!path.equals(foundPath)) { + LOGGER.log(Level.FINEST, "not matching path: ''{0}''", foundPath); return null; } } finally { From 7db007bedf58a9e4c8d2c0b5d1340d1093c7adf7 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 18 Feb 2025 17:54:36 +0100 Subject: [PATCH 3/3] log both paths --- .../main/java/org/opengrok/indexer/index/IndexDatabase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java index 0ccefb4f940..8242fe20b44 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java @@ -2124,7 +2124,8 @@ public static Document getDocument(File file) throws ParseException, IOException // Only use the document if we found an exact match. if (!path.equals(foundPath)) { - LOGGER.log(Level.FINEST, "not matching path: ''{0}''", foundPath); + LOGGER.log(Level.FINEST, "not matching path: ''{0}'' for ''{1}''", + new Object[]{foundPath, path}); return null; } } finally {