From 957288bd5fa931b2bda813d300cd655916b980bd Mon Sep 17 00:00:00 2001 From: Marc Strapetz Date: Tue, 6 Jun 2017 19:38:33 +0200 Subject: [PATCH 1/2] BigSegmentHeader: comment fixed --- .../java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java index a770c45d2..38ac2e843 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java @@ -54,7 +54,7 @@ public final class BigSegmentHeader implements SegmentHeader { /** * Previously this value was 2 seconds, but GC pauses often take more time that shouldn't - * result to IllegalStateException. + * result to InterProcessDeadLockException. */ public static final int LOCK_TIMEOUT_SECONDS = 60; From ffab7840dd4266da77719c39ecca2b1235475e52 Mon Sep 17 00:00:00 2001 From: Marc Strapetz Date: Tue, 6 Jun 2017 19:29:31 +0200 Subject: [PATCH 2/2] BigSegmentHeader: system property to specify LOCK_TIMEOUT_SECONDS The default of 60 seconds may be too long if using Chronicle-Map in a way that prevents real interprocess dead locks, i.e. InterProcessDeadLockException can only be raised if a previous Chronicle-Map process has been killed while holding a lock. In this case, a timeout of e.g 5 seconds (or less) is sufficient to detect the problem and possibly decide to invoke a recovery. --- .../chronicle/hash/impl/BigSegmentHeader.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java index 38ac2e843..e20b00f89 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/BigSegmentHeader.java @@ -52,11 +52,21 @@ public final class BigSegmentHeader implements SegmentHeader { private static final int TRY_LOCK_NANOS_THRESHOLD = 2_000_000; - /** - * Previously this value was 2 seconds, but GC pauses often take more time that shouldn't - * result to InterProcessDeadLockException. - */ - public static final int LOCK_TIMEOUT_SECONDS = 60; + public static final int LOCK_TIMEOUT_SECONDS; + + static { + // Previously this value was 2 seconds, but GC pauses often take more time that shouldn't + // result to InterProcessDeadLockException. + int timeout = 60; + try { + timeout = Integer.parseInt(System.getProperty("net.openhft.chronicle.map.lockTimeoutSeconds", String.valueOf(timeout))); + } + catch (NumberFormatException ex) { + // ignore + } + + LOCK_TIMEOUT_SECONDS = timeout; + } private static InterProcessDeadLockException deadLock() { return new InterProcessDeadLockException(