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.
This commit is contained in:
Marc Strapetz
2017-06-06 19:42:43 +02:00
parent 957288bd5f
commit ffab7840dd
@@ -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(