{"record":{"id":"4361fb16074e44ba","repo":"redis/jedis","slug":"health-check-interrupted-while-sleeping-for-s","errorCode":null,"errorMessage":"Health check interrupted while sleeping for %s.","messagePattern":"Health check interrupted while sleeping for (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/java/redis/clients/jedis/mcf/HealthCheckImpl.java","lineNumber":196,"sourceCode":"      } catch (TimeoutException | ExecutionException e) {\n        future.cancel(true);\n        if (log.isWarnEnabled()) {\n          log.warn(String.format(\"Health check timed out or failed for %s.\", endpoint), e);\n        }\n        probeContext.record(false);\n      } catch (InterruptedException e) {// Health check thread was interrupted\n        future.cancel(true);\n        Thread.currentThread().interrupt(); // Restore interrupted status\n        log.warn(String.format(\"Health check interrupted for %s.\", endpoint), e);\n        // thread interrupted, stop health check process\n        return;\n      }\n      if (!probeContext.isCompleted()) {\n        try {\n          Thread.sleep(strategy.getDelayInBetweenProbes());\n        } catch (InterruptedException e) {\n          Thread.currentThread().interrupt(); // Restore interrupted status\n          log.warn(String.format(\"Health check interrupted while sleeping for %s.\", endpoint), e);\n          // thread interrupted, stop health check process\n          return;\n        }\n      }\n    }\n\n    safeUpdate(me, probeContext.getResult());\n  }\n\n  /**\n   * just to avoid to replace status with an outdated result from another healthCheck\n   *\n   * <pre>\n   * Health Check Race Condition Prevention\n   *\n   * Problem: Async health checks can complete out of order, causing stale results\n   * to overwrite newer ones.\n   *","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/HealthCheckImpl.java#L178-L214","documentation":"During HealthCheckImpl.healthCheck, the thread sleeps between probes and, if interrupted, logs \"Health check interrupted while sleeping for <endpoint>\" as a warning, restores the interrupt flag, and returns without completing the health check. This is not a failure of the endpoint itself; it means the health-check thread was asked to stop.","triggerScenarios":"The executor/scheduler running health checks is shut down (client close, application shutdown), or the task is cancelled, while Thread.sleep(strategy.getDelayInBetweenProbes()) is in progress between failed-probe retries.","commonSituations":"Application shutdown while MultiDbClient health checks are in flight; executor reconfiguration or task cancellation; test teardown interrupting scheduled probes.","solutions":["No action needed if it occurs during shutdown — this is expected cancellation behavior.","If unexpected, audit lifecycle ordering: close health-check schedulers before/after as intended and avoid cancelling the health-check future.","Ensure your code does not call Thread.interrupt on threads owned by the health-check executor.","Check logs around the interrupt to identify which component shut down the executor."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// library handles it internally (logs warn, restores interrupt, returns).\n// At call sites shutting the client down, expect and ignore:\ntry {\n  client.close();\n} catch (Exception e) {\n  log.debug(\"shutdown noise\", e);\n}","preventionTips":["Shut down health-check executors cleanly during application shutdown.","Do not interrupt threads owned by the health-check scheduler.","Treat this warn during shutdown as expected, not a fault."],"tags":["health-check","interruption","threading","multidb"],"backgroundTag":"operation-not-supported","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"}