redis/jedis · warning

Health check interrupted while sleeping for

Error message

Health check interrupted while sleeping for %s.

What it means

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.

Solutions

  1. No action needed if it occurs during shutdown — this is expected cancellation behavior.
  2. If unexpected, audit lifecycle ordering: close health-check schedulers before/after as intended and avoid cancelling the health-check future.
  3. Ensure your code does not call Thread.interrupt on threads owned by the health-check executor.
  4. Check logs around the interrupt to identify which component shut down the executor.
Defensive patterns

Strategy: try-catch

Try / catch

// library handles it internally (logs warn, restores interrupt, returns).
// At call sites shutting the client down, expect and ignore:
try {
  client.close();
} catch (Exception e) {
  log.debug("shutdown noise", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: Application shutdown while MultiDbClient health checks are in flight; executor reconfiguration or task cancellation; test teardown interrupting scheduled probes.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/4361fb16074e44ba. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/mcf/HealthCheckImpl.java:196

      } catch (TimeoutException | ExecutionException e) {
        future.cancel(true);
        if (log.isWarnEnabled()) {
          log.warn(String.format("Health check timed out or failed for %s.", endpoint), e);
        }
        probeContext.record(false);
      } catch (InterruptedException e) {// Health check thread was interrupted
        future.cancel(true);
        Thread.currentThread().interrupt(); // Restore interrupted status
        log.warn(String.format("Health check interrupted for %s.", endpoint), e);
        // thread interrupted, stop health check process
        return;
      }
      if (!probeContext.isCompleted()) {
        try {
          Thread.sleep(strategy.getDelayInBetweenProbes());
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt(); // Restore interrupted status
          log.warn(String.format("Health check interrupted while sleeping for %s.", endpoint), e);
          // thread interrupted, stop health check process
          return;
        }
      }
    }

    safeUpdate(me, probeContext.getResult());
  }

  /**
   * just to avoid to replace status with an outdated result from another healthCheck
   *
   * <pre>
   * Health Check Race Condition Prevention
   *
   * Problem: Async health checks can complete out of order, causing stale results
   * to overwrite newer ones.
   *

View on GitHub (pinned to 6dac31d4c2)