aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-04-15 11:47:27 +0200
committerMartin Polden <mpolden@mpolden.no>2020-04-28 11:17:56 +0200
commitcb3a0e8cccd304d187e9daf421ebece25685fe43 (patch)
treee3f50f6f79f6410383fab1719d3624026a9fd418 /node-repository
parent9ace9de4dcfd14e6b7ceeddfa17946716f39a6e8 (diff)
Take both legacy lock and application lock
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
index 347c66d5426..2b64037a8b9 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java
@@ -10,8 +10,8 @@ import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.config.provision.NodeType;
import com.yahoo.config.provision.Zone;
-import java.util.logging.Level;
import com.yahoo.path.Path;
+import com.yahoo.transaction.Mutex;
import com.yahoo.transaction.NestedTransaction;
import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.curator.Curator;
@@ -364,19 +364,36 @@ public class CuratorDatabaseClient {
/** Acquires the single cluster-global, reentrant lock for active nodes of this application */
// TODO(mpolden): Remove when all config servers take the new lock
- public Lock legacyLock(ApplicationId application) {
+ public Mutex legacyLock(ApplicationId application) {
return legacyLock(application, defaultLockTimeout);
}
/** Acquires the single cluster-global, reentrant lock with the specified timeout for active nodes of this application */
// TODO(mpolden): Remove when all config servers take the new lock
- public Lock legacyLock(ApplicationId application, Duration timeout) {
+ public Mutex legacyLock(ApplicationId application, Duration timeout) {
+ Mutex legacyLock;
+ Mutex lock;
+ // Take the legacy node-repository lock
try {
- return db.lock(legacyLockPath(application), timeout);
+ legacyLock = db.lock(legacyLockPath(application), timeout);
+ } catch (UncheckedTimeoutException e) {
+ throw new ApplicationLockException(e);
}
- catch (UncheckedTimeoutException e) {
+ // Take the application lock (same as config server). This is likey already held at this point, but is
+ // re-entrant.
+ try {
+ lock = db.lock(lockPath(application), timeout);
+ } catch (UncheckedTimeoutException e) {
+ legacyLock.close();
throw new ApplicationLockException(e);
}
+ return () -> {
+ try {
+ lock.close();
+ } finally {
+ legacyLock.close();
+ }
+ };
}
/**