Prevent misleading Invalid id' error in logs
Upon git ref updates, pull-replication is fired so that remotes are
notified to perform a new fetch operation.
Small commits however (for configurable values of "small") can already
be sent as part of the payload in order to save one round-trip and be
passed directly instead.
For this reason, for each updated ref, an attempt is made to extract the
commit from the update ref.
Upon failure however, a non-useful, error message spamming the logs, as
such:
```
org.eclipse.jgit.errors.InvalidObjectIdException: Invalid id
```
Without giving any detail on what ref or what objectId actually caused
the exception, this entry is quite useless.
This was the case for example, in a multi-site installation, where the
```refs/multi-site/version```
ref was failing to be extracted (since the ref points to a blob rather
than a commit).
in fact, in a multi-site deployment this ref should be added to the
```replication.excludeRefs``` section.
Catch the InvalidObjectIdException and provide contextual information on
which ref, exactly, failed.
Bug: 14741
Change-Id: Ib0ed6f4606c72738de9296be353c4d88a2f3a88b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
index cdba012..3ded8eb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -44,6 +44,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
+import org.eclipse.jgit.errors.InvalidObjectIdException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.transport.URIish;
import org.slf4j.Logger;
@@ -189,7 +190,7 @@
if (revisionData.isPresent()) {
return ((source) -> callSendObject(source, project, refName, revisionData.get(), state));
}
- } catch (IOException | RefUpdateException e) {
+ } catch (InvalidObjectIdException | IOException | RefUpdateException e) {
stateLog.error(
String.format(
"Exception during reading ref: %s, project:%s, message: %s",
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 126cd1b..d4c5abf 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -181,6 +181,9 @@
By default, all other refs are included.
+ Note that if you are using @PLUGIN@ together with multi-site, you should
+ explicitly exclude `refs/multi-site/version` from being replicated.
+
replication.syncRefs
: Specify for which refs git fetch calls should be executed synchronously.
It can be provided more than once, and supports three formats: regular expressions,