in src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java [278:361]
private void doRunFetchOperation() {
// Lock the queue, and remove ourselves, so we can't be modified once
// we start replication (instead a new instance, with the same URI, is
// created and scheduled for a future point in time.)
//
if (!pool.requestRunway(this)) {
if (!canceled) {
repLog.info(
"Rescheduling replication to {} to avoid collision with an in-flight fetch.", uri);
pool.reschedule(this, Source.RetryReason.COLLISION);
}
return;
}
repLog.info("Replication from {} started...", uri);
Timer1.Context<String> context = metrics.start(config.getName());
try {
long startedAt = context.getStartTime();
long delay = NANOSECONDS.toMillis(startedAt - createdAt);
metrics.record(config.getName(), delay, retryCount);
git = gitManager.openRepository(projectName);
runImpl();
long elapsed = NANOSECONDS.toMillis(context.stop());
repLog.info(
"Replication from {} completed in {}ms, {}ms delay, {} retries",
uri,
elapsed,
delay,
retryCount);
} catch (RepositoryNotFoundException e) {
stateLog.error(
"Cannot replicate " + projectName + "; Local repository error: " + e.getMessage(),
getStatesAsArray());
} catch (NoRemoteRepositoryException | RemoteRepositoryException e) {
// Tried to replicate to a remote via anonymous git:// but the repository
// does not exist. In this case NoRemoteRepositoryException is not
// raised.
String msg = e.getMessage();
repLog.error("Cannot replicate {}; Remote repository error: {}", projectName, msg);
} catch (NotSupportedException e) {
stateLog.error("Cannot replicate from " + uri, e, getStatesAsArray());
} catch (TransportException e) {
Throwable cause = e.getCause();
if (e instanceof LockFailureException) {
lockRetryCount++;
// The LockFailureException message contains both URI and reason
// for this failure.
repLog.error("Cannot replicate from {}: {}", uri, e.getMessage());
// The remote fetch operation should be retried.
if (lockRetryCount <= maxLockRetries) {
if (canceledWhileRunning.get()) {
logCanceledWhileRunningException(e);
} else {
pool.reschedule(this, Source.RetryReason.TRANSPORT_ERROR);
}
} else {
repLog.error(
"Giving up after {} occurrences of this error: {} during replication from {}",
lockRetryCount,
e.getMessage(),
uri);
}
} else {
if (canceledWhileRunning.get()) {
logCanceledWhileRunningException(e);
} else {
repLog.error("Cannot replicate from {}", uri, e);
// The remote fetch operation should be retried.
pool.reschedule(this, Source.RetryReason.TRANSPORT_ERROR);
}
}
} catch (IOException e) {
stateLog.error("Cannot replicate from " + uri, e, getStatesAsArray());
} catch (RuntimeException | Error e) {
stateLog.error("Unexpected error during replication from " + uri, e, getStatesAsArray());
} finally {
if (git != null) {
git.close();
}
pool.notifyFinished(this);
}
}