Skip to content

Commit 3228655

Browse files
committed
pool: Configure timeout for pool to pool transfer
Addresses the issue that a pool to pool transfer does not time out if the underlying TCP connection "gets stuck". Back when we used DCAP for pool to pool transfers, we configured TCP keep alive to ensure that we eventually get a timeout if the TCP stacks of the two operating systems disagree about the state of the TCP connection. Ever since we switched to HTTP, this functionality was lost. At NDGF we observed a situation in which a migration from one pool to another got stuck because the TCP connection got into an inconsistent state. The target pool saw the connection as established, while the source pool no longer had a connection. The transfer forever stayed in the DoorFinished state, as dCache expected that the TCP connection would eventually be closed (since dCache knew it had been closed on the source pool already). We cannot get Sun's HTTP client to enable TCP keep alive, however we can configure connect and read timeouts. Since we only ever need these timeouts for the rare case when the OSes get confused, I don't see a reason to make these values end user configurable. I have simply hard coded some conservative timeout values. Target: trunk Request: 2.6 Request: 2.2 Require-notes: yes Require-book: no Acked-by: Paul Millar <paul.millar@desy.de> Patch: http://rb.dcache.org/r/5556/ (cherry picked from commit 7de28ba)
1 parent 73b5aa4 commit 3228655

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

modules/dcache/src/main/java/org/dcache/pool/p2p/Companion.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class Companion
7575
private final static int PROTOCOL_INFO_MINOR_VERSION = 1;
7676

7777
private final static AtomicInteger _nextId = new AtomicInteger(100);
78+
private static final long CONNECT_TIMEOUT = TimeUnit.MINUTES.toMillis(5);
79+
private static final long READ_TIMEOUT = TimeUnit.MINUTES.toMillis(10);
7880

7981
private final InetAddress _address;
8082
private final Repository _repository;
@@ -324,6 +326,8 @@ private HttpURLConnection createConnection(String uri)
324326
HttpURLConnection connection =
325327
(HttpURLConnection) url.openConnection();
326328
connection.setRequestProperty("Connection", "close");
329+
connection.setConnectTimeout((int) CONNECT_TIMEOUT);
330+
connection.setReadTimeout((int) READ_TIMEOUT);
327331
connection.connect();
328332
return connection;
329333
}

0 commit comments

Comments
 (0)