{"record":{"id":"544a800df20c5776","repo":"redis/jedis","slug":"error-while-checking-availability","errorCode":null,"errorMessage":"Error while checking availability","messagePattern":"Error while checking availability","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/mcf/LagAwareStrategy.java","lineNumber":89,"sourceCode":"          bdbId = bdb;\n        }\n      }\n      if (this.config.isExtendedCheckEnabled()) {\n        // Use extended check with lag validation\n        if (redisRestAPI.checkBdbAvailability(bdb, true,\n          this.config.getAvailabilityLagTolerance().toMillis())) {\n          return HealthStatus.HEALTHY;\n        }\n      } else {\n        // Use standard datapath validation only\n        if (redisRestAPI.checkBdbAvailability(bdb, false)) {\n          return HealthStatus.HEALTHY;\n        }\n      }\n    } catch (Exception e) {\n      log.error(\"Error while checking database availability\", e);\n      bdbId = null;\n      throw new JedisException(\"Error while checking availability\", e);\n    }\n    return HealthStatus.UNHEALTHY;\n  }\n\n  public static class Config extends HealthCheckStrategy.Config {\n\n    public static final boolean EXTENDED_CHECK_DEFAULT = true;\n    public static final Duration AVAILABILITY_LAG_TOLERANCE_DEFAULT = Duration.ofMillis(5000);\n\n    private final Endpoint restEndpoint;\n    private final Supplier<RedisCredentials> credentialsSupplier;\n\n    // SSL configuration for HTTPS connections to Redis Enterprise REST API\n    private final SslOptions sslOptions;\n\n    // Maximum acceptable lag in milliseconds (default: 5000);\n    private final Duration availability_lag_tolerance;\n","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/LagAwareStrategy.java#L71-L107","documentation":"Thrown by LagAwareStrategy.doHealthCheck when any unexpected exception occurs while probing a database endpoint's availability. The health check catches the underlying exception, logs it, clears the resolved bdbId, and rethrows it wrapped in a JedisException so the health status manager can treat the endpoint as unreachable/unresolvable.","triggerScenarios":"Calling LagAwareStrategy.doHealthCheck() when the underlying availability probe (connection to the endpoint or the BDB-id lookup) throws any Exception — e.g. connection failure, timeout, or DNS resolution error inside the check.","commonSituations":"Redis endpoint is down or unreachable from the client; network partition or firewall blocking the health-check port; wrong endpoint/host configured; transient DNS failures in containerized/Kubernetes environments.","solutions":["Verify the configured endpoint host/port is reachable (test with redis-cli -h <host> -p <port> PING).","Check network connectivity: firewalls, security groups, and DNS resolution for the endpoint host.","Inspect the logged cause ('Error while checking database availability') to identify the root exception.","If transient, rely on the health status manager's retry/failover to another healthy database instead of failing fast."],"exampleFix":"// before: health check hits a dead endpoint and surfaces raw failure\nLagAwareStrategy.Config cfg = LagAwareStrategy.Config.builder(endpoint, credsSupplier).build();\n\n// after: ensure endpoint is valid and strategy failure is handled by failover\nMultiDbConfig cfg = MultiDbConfig.builder(endpoint)\n    .connectionPoolConfig(poolCfg)\n    .healthCheckEnabled(true)\n    .build();\n// handle JedisException from health checks via failover listener, not by crashing","handlingStrategy":"try-catch","validationCode":"// before running health checks, verify reachability yourself\ntry (Socket s = new Socket(endpoint.getHost(), endpoint.getPort())) {\n  // endpoint reachable\n}","typeGuard":null,"tryCatchPattern":"try {\n  strategy.doHealthCheck();\n} catch (JedisException e) {\n  log.warn(\"Health check failed for endpoint\", e);\n  // mark endpoint unhealthy / trigger failover\n}","preventionTips":["Validate endpoint host/port reachability at startup.","Ensure DNS resolves reliably in your deployment environment.","Configure reasonable health-check timeouts and retry policies.","Let the health status manager fail over instead of propagating the exception to application logic."],"tags":["health-check","network","failover","multi-db"],"backgroundTag":"health-check-failed","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}