From 16db002a0bfe6559a6395dabf155b7a8bfadc968 Mon Sep 17 00:00:00 2001 From: Gustaf Lundh Date: Mon, 13 Apr 2015 12:40:35 +0200 Subject: Set connection timeout to 120 sec for SSH remote operations 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 --- .../com/googlesource/gerrit/plugins/replication/ReplicationQueue.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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() { -- cgit v1.2.3