summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-10-12 17:46:06 +0200
committerGitHub <noreply@github.com>2020-10-12 17:46:06 +0200
commite8b3dd2b51d9d4e9f4fd4a9464d966bb7d050045 (patch)
tree254d00d2e81d4141e3c45d191d20ca265e20a2dc /configserver
parent61ba6799cad6cb8851e101ebbb59287c0a4b13d0 (diff)
parentbcdbf50626e52e5d79fc0c1cc06ac66ce76f3531 (diff)
Merge pull request #14823 from vespa-engine/mpolden/hold-lock-on-commit
Hold lock while committing transaction
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index cfccd0f7e16..ff02ddb700f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -510,18 +510,21 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// This call will remove application in zookeeper. Watches in TenantApplications will remove the application
// and allocated hosts in model and handlers in RPC server
transaction.add(tenantApplications.createDeleteTransaction(applicationId));
+ transaction.onCommitted(() -> log.log(Level.INFO, "Deleted " + applicationId));
- hostProvisioner.ifPresent(provisioner -> {
+ if (hostProvisioner.isPresent()) {
if (acquireProvisionLock.value()) {
- try (var provisionLock = provisioner.lock(applicationId)) {
- provisioner.remove(transaction, provisionLock);
+ try (var provisionLock = hostProvisioner.get().lock(applicationId)) {
+ hostProvisioner.get().remove(transaction, provisionLock);
+ transaction.commit();
}
- } else {
- provisioner.remove(transaction, applicationId);
+ } else { // TODO(mpolden): Remove when feature flag is removed
+ hostProvisioner.get().remove(transaction, applicationId);
+ transaction.commit();
}
- });
- transaction.onCommitted(() -> log.log(Level.INFO, "Deleted " + applicationId));
- transaction.commit();
+ } else {
+ transaction.commit();
+ }
return true;
}
}
@@ -737,16 +740,19 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
CompletionWaiter waiter = session.getSessionZooKeeperClient().createActiveWaiter();
NestedTransaction transaction = new NestedTransaction();
transaction.add(deactivateCurrentActivateNew(previousActiveSession, session, force));
- hostProvisioner.ifPresent(provisioner -> {
- if (acquireProvisionLock.value()) {
- try (var lock = provisioner.lock(applicationId)) {
- provisioner.activate(transaction, session.getAllocatedHosts().getHosts(), lock);
- }
- } else {
- provisioner.activate(transaction, applicationId, session.getAllocatedHosts().getHosts());
- }
- });
- transaction.commit();
+ if (hostProvisioner.isPresent()) {
+ if (acquireProvisionLock.value()) {
+ try (var lock = hostProvisioner.get().lock(applicationId)) {
+ hostProvisioner.get().activate(transaction, session.getAllocatedHosts().getHosts(), lock);
+ transaction.commit();
+ }
+ } else { // TODO(mpolden): Remove when feature flag is removed
+ hostProvisioner.get().activate(transaction, applicationId, session.getAllocatedHosts().getHosts());
+ transaction.commit();
+ }
+ } else {
+ transaction.commit();
+ }
return waiter;
}