summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustaf Lundh <gustaf.lundh@sonymobile.com>2015-04-13 12:40:35 +0200
committerGustaf Lundh <gustaf.lundh@sonymobile.com>2015-04-14 09:05:09 +0000
commit16db002a0bfe6559a6395dabf155b7a8bfadc968 (patch)
tree0c79f9bfa6efee5adb946aab485fb2bb04acf36f
parentae055c09e13b95278a795b4f5eb45dbe8b99a140 (diff)
Set connection timeout to 120 sec for SSH remote operationsv2.10.8v2.10.7v2.10.6v2.10.5v2.10.4v2.10.3.1v2.10.3upstream/stable-2.10
The creation of a missing Git, before starting replication, is a blocking operation. By setting a timeout on the synchronized getSession(), we ensure the operation does not get stuck forever, essentially blocking all future remote git creation operations. 120 seconds is an arbitrary limit, chosen because it should be enough to not risk being triggered unnecessarily. This is a fail-safe and we should hopefully very rarely end up needing the timeout. Change-Id: I01ed29004c6c75a75ede918f61fa1c68d246150b
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
index 8be6b21..a34ac1c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -62,6 +62,7 @@ class ReplicationQueue implements
HeadUpdatedListener {
static final String REPLICATION_LOG_NAME = "replication_log";
static final Logger repLog = LoggerFactory.getLogger(REPLICATION_LOG_NAME);
+ private static final int SSH_REMOTE_TIMEOUT = 120 * 1000;
private static final ReplicationStateLogger stateLog =
new ReplicationStateLogger(repLog);
@@ -413,7 +414,8 @@ class ReplicationQueue implements
}
private static RemoteSession connect(URIish uri) throws TransportException {
- return SshSessionFactory.getInstance().getSession(uri, null, FS.DETECTED, 0);
+ return SshSessionFactory.getInstance().getSession(uri, null, FS.DETECTED,
+ SSH_REMOTE_TIMEOUT);
}
private static OutputStream newErrorBufferStream() {