summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarius Jokilehto <dariusjokilehto+os@gmail.com>2023-04-21 14:53:45 +0100
committerDarius Jokilehto <dariusjokilehto+os@gmail.com>2023-04-28 13:51:58 +0100
commitcc386031455272cc57b20174469353677e279d9c (patch)
tree9a41558a844b95cc823177e9458ee07dfe8556b2
parent21ef86b703f2d353d000abf7e9cb34749c62fbc5 (diff)
Log external ID differential cache loader failure
We've investigated this issue and tried different ways of getting this to fail, but haven't been successful. We've investigated the algorithm, but haven't found any faults. We also considered concurrency, but as we lock the cache before calling the differential loader, we're not sure how that could be the issue. We've managed to recreate the issue by fudging the input to the private method, where we pass a key to `additions` that is already present in the cache, but we don't see how that would be possible from the public `load` entrypoint. In order to continue the investigation we require more information, we have opted to add some further logs when the differential cache loader errors. We now log the tip of the external ID cache as well as the external ID ref on disk. We also log the set of additions, to confirm a key clash. Bug: Issue 16384 Release-Notes: skip Change-Id: I3836f28285b4fdcfd2e26720bdbf82cf046960c7
-rw-r--r--java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java b/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
index 27672bdcf6..43e316a978 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
@@ -43,7 +43,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@@ -184,8 +186,17 @@ public class ExternalIdCacheLoader {
}
}
- AllExternalIds allExternalIds =
- buildAllExternalIds(repo, oldExternalIds, additions, removals);
+ AllExternalIds allExternalIds;
+ try {
+ allExternalIds = buildAllExternalIds(repo, oldExternalIds, additions, removals);
+ } catch (IllegalArgumentException e) {
+ Set<String> additionKeys =
+ additions.keySet().stream().map(AnyObjectId::getName).collect(Collectors.toSet());
+ logger.atSevere().withCause(e).log(
+ "Failed to load external ID cache. Repository ref is %s, cache ref is %s, additions are %s",
+ extIdRef.getObjectId().getName(), parentWithCacheValue.getId().getName(), additionKeys);
+ throw e;
+ }
reloadCounter.increment(true);
reloadDifferential.record(System.nanoTime() - start, TimeUnit.NANOSECONDS);
return allExternalIds;