diff options
9 files changed, 44 insertions, 15 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java index e316f826ad6..8907c21d39a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.model.container; import ai.vespa.metricsproxy.http.application.ApplicationMetricsHandler; +import com.yahoo.cloud.config.CuratorConfig; import com.yahoo.cloud.config.ZookeeperServerConfig; import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; @@ -305,6 +306,15 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat } } + @Override + public void getConfig(CuratorConfig.Builder builder) { + if (getParent() instanceof ConfigserverCluster) return; // Produces its own config + super.getConfig(builder); + + // 12s is 2x the current ZookeeperServerConfig.tickTime() of 6s, and the default minimum the server will accept. + builder.zookeeperSessionTimeoutSeconds(12); // TODO jonmv: make configurable + } + public Optional<String> getTlsClientAuthority() { return tlsClientAuthority; } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java index 376cf49c396..eb77187014f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/ClusterControllerTestCase.java @@ -413,6 +413,11 @@ public class ClusterControllerTestCase extends DomBuilderTest { assertEquals(0, qrStartConfig.jvm().directMemorySizeCache()); assertEquals(16, qrStartConfig.jvm().baseMaxDirectMemorySize()); + CuratorConfig.Builder curatorBuilder = new CuratorConfig.Builder(); + model.getConfig(curatorBuilder, "foo"); + CuratorConfig curatorConfig = curatorBuilder.build(); + assertEquals(120, curatorConfig.zookeeperSessionTimeoutSeconds()); + assertReindexingConfigPresent(model); assertReindexingConfiguredOnAdminCluster(model); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java index cc6b84de698..da70daa2b4d 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/ContainerClusterTest.java @@ -343,6 +343,7 @@ public class ContainerClusterTest { assertEquals(List.of("host-c1", "host-c2"), config.server().stream().map(CuratorConfig.Server::hostname).collect(Collectors.toList())); assertTrue(config.zookeeperLocalhostAffinity()); + assertEquals(12, config.zookeeperSessionTimeoutSeconds()); } @Test diff --git a/configdefinitions/src/vespa/curator.def b/configdefinitions/src/vespa/curator.def index c762766a567..db7cea00882 100644 --- a/configdefinitions/src/vespa/curator.def +++ b/configdefinitions/src/vespa/curator.def @@ -7,3 +7,6 @@ server[].port int default=2181 # if true, only connect to server on localhost (must be in one of the servers above) zookeeperLocalhostAffinity bool default=false + +# session timeout, the high default is used by config servers +zookeeperSessionTimeoutSeconds int default=120
\ No newline at end of file diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriterLRUCache.java b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriterLRUCache.java index c499c1c3054..c2be7f98f15 100644 --- a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriterLRUCache.java +++ b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriterLRUCache.java @@ -10,7 +10,6 @@ import java.util.Map; /** * @author Bjorn Borud */ -@SuppressWarnings("serial") public class LogWriterLRUCache extends LinkedHashMap<Integer, LogWriter> { private static final Logger log = Logger.getLogger(LogWriterLRUCache.class.getName()); diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java index 1da51beef29..ab35ccf545e 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java @@ -63,8 +63,8 @@ public class Curator extends AbstractComponent implements AutoCloseable { private static final Logger LOG = Logger.getLogger(Curator.class.getName()); private static final File ZK_CLIENT_CONFIG_FILE = new File(Defaults.getDefaults().underVespaHome("conf/zookeeper/zookeeper-client.cfg")); - // Note that session timeout has min and max values are related to tickTime defined by server, see configserver.def - static final Duration ZK_SESSION_TIMEOUT = Duration.ofSeconds(120); + // Note that session timeout has min and max values are related to tickTime defined by server, see zookeeper-server.def + static final Duration DEFAULT_ZK_SESSION_TIMEOUT = Duration.ofSeconds(120); private static final Duration ZK_CONNECTION_TIMEOUT = Duration.ofSeconds(30); private static final Duration BASE_SLEEP_TIME = Duration.ofSeconds(1); @@ -76,18 +76,21 @@ public class Curator extends AbstractComponent implements AutoCloseable { private final CuratorFramework curatorFramework; private final ConnectionSpec connectionSpec; private final long juteMaxBuffer; + private final Duration sessionTimeout; // All lock keys, to allow re-entrancy. This will grow forever, but this should be too slow to be a problem private final ConcurrentHashMap<Path, Lock> locks = new ConcurrentHashMap<>(); /** Creates a curator instance from a comma-separated string of ZooKeeper host:port strings */ public static Curator create(String connectionSpec) { - return new Curator(ConnectionSpec.create(connectionSpec), Optional.of(ZK_CLIENT_CONFIG_FILE), defaultJuteMaxBuffer); + return new Curator(ConnectionSpec.create(connectionSpec), Optional.of(ZK_CLIENT_CONFIG_FILE), + defaultJuteMaxBuffer, DEFAULT_ZK_SESSION_TIMEOUT); } // For testing only, use Optional.empty for clientConfigFile parameter to create default zookeeper client config public static Curator create(String connectionSpec, Optional<File> clientConfigFile) { - return new Curator(ConnectionSpec.create(connectionSpec), clientConfigFile, defaultJuteMaxBuffer); + return new Curator(ConnectionSpec.create(connectionSpec), clientConfigFile, + defaultJuteMaxBuffer, DEFAULT_ZK_SESSION_TIMEOUT); } @Inject @@ -98,31 +101,35 @@ public class Curator extends AbstractComponent implements AutoCloseable { CuratorConfig.Server::port, curatorConfig.zookeeperLocalhostAffinity()), Optional.of(ZK_CLIENT_CONFIG_FILE), - defaultJuteMaxBuffer); + defaultJuteMaxBuffer, + Duration.ofSeconds(curatorConfig.zookeeperSessionTimeoutSeconds())); } protected Curator(String connectionSpec, String zooKeeperEnsembleConnectionSpec, Function<RetryPolicy, CuratorFramework> curatorFactory) { - this(ConnectionSpec.create(connectionSpec, zooKeeperEnsembleConnectionSpec), curatorFactory.apply(DEFAULT_RETRY_POLICY), defaultJuteMaxBuffer); + this(ConnectionSpec.create(connectionSpec, zooKeeperEnsembleConnectionSpec), curatorFactory.apply(DEFAULT_RETRY_POLICY), + defaultJuteMaxBuffer, DEFAULT_ZK_SESSION_TIMEOUT); } - Curator(ConnectionSpec connectionSpec, Optional<File> clientConfigFile, long juteMaxBuffer) { + Curator(ConnectionSpec connectionSpec, Optional<File> clientConfigFile, long juteMaxBuffer, Duration sessionTimeout) { this(connectionSpec, CuratorFrameworkFactory .builder() .retryPolicy(DEFAULT_RETRY_POLICY) - .sessionTimeoutMs((int) ZK_SESSION_TIMEOUT.toMillis()) + .sessionTimeoutMs((int) sessionTimeout.toMillis()) .connectionTimeoutMs((int) ZK_CONNECTION_TIMEOUT.toMillis()) .connectString(connectionSpec.local()) .zookeeperFactory(new VespaZooKeeperFactory(createClientConfig(clientConfigFile))) .dontUseContainerParents() // TODO: Consider changing this in Vespa 9 .build(), - juteMaxBuffer); + juteMaxBuffer, + sessionTimeout); } - private Curator(ConnectionSpec connectionSpec, CuratorFramework curatorFramework, long juteMaxBuffer) { + private Curator(ConnectionSpec connectionSpec, CuratorFramework curatorFramework, long juteMaxBuffer, Duration sessionTimeout) { this.connectionSpec = Objects.requireNonNull(connectionSpec); this.curatorFramework = Objects.requireNonNull(curatorFramework); this.juteMaxBuffer = juteMaxBuffer; + this.sessionTimeout = sessionTimeout; addLoggingListener(); curatorFramework.start(); } @@ -141,6 +148,10 @@ public class Curator extends AbstractComponent implements AutoCloseable { } } + public Duration sessionTimeout() { + return sessionTimeout; + } + /** For internal use; prefer creating a {@link CuratorCounter} */ public DistributedAtomicLong createAtomicCounter(String path) { return new DistributedAtomicLong(curatorFramework, path, new ExponentialBackoffRetry((int) BASE_SLEEP_TIME.toMillis(), MAX_RETRIES)); diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/SingletonManager.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/SingletonManager.java index e54197c39fd..2658bcce686 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/SingletonManager.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/SingletonManager.java @@ -293,7 +293,7 @@ class SingletonManager { logger.log(FINE, "Failed pinging ZK cluster", e); return; } - if ( ! doom.compareAndSet(ourDoom, start.plus(Curator.ZK_SESSION_TIMEOUT.multipliedBy(9).dividedBy(10)))) { + if ( ! doom.compareAndSet(ourDoom, start.plus(curator.sessionTimeout().multipliedBy(9).dividedBy(10)))) { logger.log(FINE, "Deadline changed, current lease renewal is void"); } } diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java index 71eae121313..3ace79ecc67 100644 --- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java +++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorTest.java @@ -82,7 +82,8 @@ public class CuratorTest { CuratorConfig.Server::port, curatorConfig.zookeeperLocalhostAffinity()), Optional.empty(), - juteMaxBuffer); + juteMaxBuffer, + Curator.DEFAULT_ZK_SESSION_TIMEOUT); } } diff --git a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorWrapperTest.java b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorWrapperTest.java index ab27dbbcc7b..5eb38c559a9 100644 --- a/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorWrapperTest.java +++ b/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorWrapperTest.java @@ -11,7 +11,6 @@ import com.yahoo.vespa.curator.mock.MockCuratorFramework; import org.apache.curator.framework.state.ConnectionState; import org.junit.Test; -import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.util.List; @@ -112,7 +111,7 @@ public class CuratorWrapperTest { stunning.arriveAndAwaitAdvance(); // Wait for next renewLease. stunning.arriveAndAwaitAdvance(); // Let next renewLease complete. stunning.arriveAndAwaitAdvance(); // Wait for next updateStatus. - clock.advance(Curator.ZK_SESSION_TIMEOUT); + clock.advance(wrapped.sessionTimeout()); singleton.phaser.register(); // Set up so we can synchronise with deactivation. stunning.forceTermination(); // Let lease expire, and ensure further ticks complete if we lose the race to unregister. |