{"record":{"id":"09a4b0976a297fb4","repo":"apache/druid","slug":"leadersessionttl-is-s-leader-failover-may-take-u","errorCode":null,"errorMessage":"leaderSessionTtl is %s; leader failover may take up to %s","messagePattern":"leaderSessionTtl is (.+?); leader failover may take up to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extensions-contrib/consul-extensions/src/main/java/org/apache/druid/consul/discovery/ConsulLeaderSelector.java","lineNumber":96,"sourceCode":"  private ScheduledExecutorService sessionKeeperService;\n  private volatile String sessionId;\n  private volatile boolean stopping = false;\n  private long errorRetryCount = 0;\n\n  public ConsulLeaderSelector(\n      DruidNode self,\n      String lockKey,\n      ConsulDiscoveryConfig config,\n      ConsulClient consulClient\n  )\n  {\n    this.self = Preconditions.checkNotNull(self, \"self\");\n    this.lockKey = Preconditions.checkNotNull(lockKey, \"lockKey\");\n    this.config = Preconditions.checkNotNull(config, \"config\");\n    this.consulClient = Preconditions.checkNotNull(consulClient, \"consulClient\");\n\n    if (config.getLeader().getLeaderSessionTtl().getStandardSeconds() > 120) {\n      LOGGER.warn(\"leaderSessionTtl is %s; leader failover may take up to %s\",\n                  config.getLeader().getLeaderSessionTtl(),\n                  Duration.standardSeconds(config.getLeader().getLeaderSessionTtl().getStandardSeconds() * 2));\n    }\n  }\n\n  @Nullable\n  @Override\n  public String getCurrentLeader()\n  {\n    try {\n      Response<GetValue> response = consulClient.getKVValue(\n          lockKey,\n          config.getAuth().getAclToken(),\n          buildQueryParams()\n      );\n      if (response != null && response.getValue() != null && response.getValue().getValue() != null) {\n        return new String(Base64.getDecoder().decode(response.getValue().getValue()), StandardCharsets.UTF_8);\n      }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/consul-extensions/src/main/java/org/apache/druid/consul/discovery/ConsulLeaderSelector.java#L78-L114","documentation":"A constructor-time warning logged when the configured Consul leader session TTL exceeds 120 seconds. Consul sessions must be renewed before the TTL lapses; a long TTL means that when a leader dies ungracefully, other nodes may wait up to roughly twice the TTL (lock-delay plus session expiry) before they can acquire the lock. The library logs this so operators know failover will be slow.","triggerScenarios":"Constructing ConsulLeaderSelector with a ConsulDiscoveryConfig whose leader.leaderSessionTtl duration is set to more than 120 seconds (e.g. druid.discovery.consul.leader.sessionTtl=PT5M in properties).","commonSituations":"Operators tuning the TTL upward to 'reduce renewal churn' after seeing renewal warnings, copying a config from a deployment that tolerated slow failover, or misconfiguring the duration unit (e.g. hours instead of seconds).","solutions":["Lower leaderSessionTtl to 120 seconds or less (a value like 30-60s is typical) and rely on the session keeper's renewal at healthCheckInterval/3.","If slow failover is unacceptable for your service, keep TTL <= 120s and shorten healthCheckInterval so renewals are frequent.","If failover latency is acceptable, set the TTL to <= 120s or consciously accept the documented risk."],"exampleFix":"// before\ndruid.discovery.consul.leader.sessionTtl=PT10M\n// after\ndruid.discovery.consul.leader.sessionTtl=PT60S","handlingStrategy":"validation","validationCode":"if (config.getLeader().getLeaderSessionTtl().getStandardSeconds() > 120) {\n  throw new IllegalArgumentException(\"leaderSessionTtl must be <= 120s for prompt failover, got: \"\n      + config.getLeader().getLeaderSessionTtl());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep leaderSessionTtl between 10s and 120s","Set healthCheckInterval to at most a third of the TTL","Review Consul leader-election tuning docs before changing TTLs"],"tags":["consul","leader-election","configuration","ttl","failover"],"backgroundTag":"invalid-config-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}