From d791834dee91671917a2a70a55c7ffdfcf72df60 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Wed, 31 Jan 2018 17:58:12 +0100 Subject: Remove synchronization, it leads to deadlocks Example: Thread A gets the lock in acquire(), does not hold the monitor anymore.. Thread B calls acquire() and waits for the lock (while holding the monitor) Thead A wants to call release(), but cannot do that because thread B is holding the monitor. Deadlock until timeout for thread A, at which time thread B holds the monitor again and continues --- .../main/java/com/yahoo/vespa/config/server/tenant/ActivateLock.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'configserver') diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/ActivateLock.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/ActivateLock.java index 461992412d2..c49d476c4c4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/ActivateLock.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/ActivateLock.java @@ -23,7 +23,7 @@ public class ActivateLock { this.curatorLock = new CuratorLock(curator, rootPath.append(ACTIVATE_LOCK_NAME).getAbsolute()); } - public synchronized boolean acquire(TimeoutBudget timeoutBudget, boolean ignoreLockError) { + public boolean acquire(TimeoutBudget timeoutBudget, boolean ignoreLockError) { try { return curatorLock.tryLock(timeoutBudget.timeLeft().toMillis(), TimeUnit.MILLISECONDS); } catch (Exception e) { @@ -34,7 +34,7 @@ public class ActivateLock { } } - public synchronized void release() { + public void release() { if (curatorLock.hasLock()) { curatorLock.unlock(); } -- cgit v1.2.3