{"record":{"id":"74e9f1d09f6c5b35","repo":"redis/jedis","slug":"database-is-not-healthy","errorCode":null,"errorMessage":"Database is not healthy","messagePattern":"Database is not healthy","errorType":"exception","errorClass":"JedisConnectionException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java","lineNumber":892,"sourceCode":"\n    private Database(Endpoint endpoint, TrackingConnectionPool connectionPool, Retry retry,\n        HealthCheck hc, CircuitBreaker circuitBreaker, float weight, MultiDbConfig multiDbConfig) {\n\n      this.endpoint = endpoint;\n      this.connectionPool = connectionPool;\n      this.retry = retry;\n      this.circuitBreaker = circuitBreaker;\n      this.weight = weight;\n      this.multiDbConfig = multiDbConfig;\n      this.healthCheck = hc;\n    }\n\n    public Endpoint getEndpoint() {\n      return endpoint;\n    }\n\n    public Connection getConnection() {\n      if (!isHealthy()) throw new JedisConnectionException(\"Database is not healthy\");\n      if (connectionPool.isClosed()) {\n        connectionPool = TrackingConnectionPool.from(connectionPool);\n      }\n      return connectionPool.getResource();\n    }\n\n    @VisibleForTesting\n    public ConnectionPool getConnectionPool() {\n      return connectionPool;\n    }\n\n    public Retry getRetry() {\n      return retry;\n    }\n\n    public CircuitBreaker getCircuitBreaker() {\n      return circuitBreaker;\n    }","sourceCodeStart":874,"sourceCodeEnd":910,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java#L874-L910","documentation":"MultiDbConnectionProvider wraps per-database connection pools and routes commands to the currently active database. Each pooled endpoint exposes a health flag; getConnection() refuses to hand out a connection from a pool whose isHealthy() check fails, throwing JedisConnectionException(\"Database is not healthy\"). This guards callers from issuing commands to a database that the failover/health-tracking logic has marked down.","triggerScenarios":"Calling ConnectionPooled.getConnection() (or any provider path that fetches a connection from this pool) after the endpoint's health status became unhealthy — e.g. health checks failed, the database was marked inactive during failover, or the connection to that endpoint was lost.","commonSituations":"Redis Enterprise BDB failover in progress; the configured active endpoint was taken down or restarted; network partition causing the health checker to flag the pool; client pointing at a replica/endpoint that is no longer serving.","solutions":["Check endpoint health before use (provider isHealthy()/active endpoint) and fail over to another database before issuing commands","Retry against the provider after failover completes — the failover executor usually selects a healthy database automatically","Verify the target database is actually running and reachable (network, firewall, Redis process)","Inspect health/failover configuration (health check intervals, SslVerifyMode, endpoints list) in the MultiDbClient builder"],"exampleFix":"// before\nConnection conn = provider.getConnection(); // throws if pool unhealthy\n// after\nif (provider.isHealthy(endpoint)) {\n  Connection conn = provider.getConnection();\n} else {\n  provider.failoverToAnotherDatabase(endpoint, true);\n  Connection conn = provider.getConnection();\n}","handlingStrategy":"try-catch","validationCode":"if (!provider.isHealthy(activeEndpoint)) { provider.failoverToAnotherDatabase(activeEndpoint, true); }","typeGuard":"boolean usable(ConnectionPooled pool) { return pool != null && pool.isHealthy(); }","tryCatchPattern":"try { Connection c = provider.getConnection(); ... } catch (JedisConnectionException e) { provider.failoverToAnotherDatabase(endpoint, true); /* retry */ }","preventionTips":["Check isHealthy() on the target endpoint before fetching connections","Configure aggressive health checks and automatic failover in the MultiDbClient builder","Monitor failover events and metrics for endpoint downtime"],"tags":["redis","failover","connection-pool","health-check"],"backgroundTag":"connection-refused","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"}