{"record":{"id":"07d46486ce524c6d","repo":"redis/jedis","slug":"retry-deadline-exceeded","errorCode":null,"errorMessage":"Retry deadline exceeded.","messagePattern":"Retry deadline exceeded\\.","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/executors/RetryableCommandExecutor.java","lineNumber":71,"sourceCode":"\n        return execute(connection, commandObject);\n\n      } catch (JedisConnectionException jce) {\n        lastException = jce;\n        ++consecutiveConnectionFailures;\n        log.debug(\"Failed connecting to Redis: {}\", connection, jce);\n        // \"- 1\" because we just did one, but the attemptsLeft counter hasn't been decremented yet\n        boolean reset = handleConnectionProblem(attemptsLeft - 1, consecutiveConnectionFailures, deadline);\n        if (reset) {\n          consecutiveConnectionFailures = 0;\n        }\n      } finally {\n        if (connection != null) {\n          connection.close();\n        }\n      }\n      if (Instant.now().isAfter(deadline)) {\n        throw new JedisException(\"Retry deadline exceeded.\");\n      }\n    }\n\n    JedisException maxAttemptsException = new JedisException(\"No more attempts left.\");\n    if (lastException != null) {\n      maxAttemptsException.addSuppressed(lastException);\n    }\n    throw maxAttemptsException;\n  }\n\n  /**\n   * WARNING: This method is accessible for the purpose of testing.\n   * This should not be used or overriden.\n   */\n  @VisibleForTesting\n  protected <T> T execute(Connection connection, CommandObject<T> commandObject) {\n    return connection.executeCommand(commandObject);\n  }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/executors/RetryableCommandExecutor.java#L53-L89","documentation":"RetryableCommandExecutor executes a command with configurable retries against pooled connections. When the retry deadline (derived from the configured timeout/maxAttempts) passes after an attempt, it throws JedisException(\"Retry deadline exceeded.\"), suppressing the last underlying exception. It means the command failed repeatedly and the retry time budget is exhausted.","triggerScenarios":"Command execution keeps failing (connection refused, socket timeout, broken connection to a standalone/multi-db endpoint) across attempts until Instant.now() exceeds the deadline inside executeCommand.","commonSituations":"Redis server down or restarted; connection pool exhausted (pool block timeouts counted as failures); network instability to a standalone or MultiDb endpoint; deadlines too short for the configured maxAttempts.","solutions":["Check the suppressed cause for the real failure (connect refused vs timeout) and verify Redis is reachable at the configured endpoint.","Increase the retry timeout/maxAttempts in the client or RetryableCommandExecutor configuration.","Fix pool sizing (increase max pool size / set sane maxWait) if pool exhaustion is the underlying failure.","Reduce per-attempt socket timeout so attempts fit inside the deadline."],"exampleFix":"// before\nRedisClient.create(\"redis://localhost:6379\")\n    .build();\n// after\nRedisClient.create(\"redis://localhost:6379\")\n    .socketTimeout(Duration.ofSeconds(2))\n    .maxAttempts(15)\n    .build();","handlingStrategy":"try-catch","validationCode":"try (Jedis j = new Jedis(host, port, 2000)) {\n  j.ping(); // endpoint reachable before using the retrying executor\n}","typeGuard":null,"tryCatchPattern":"try {\n  return executor.executeCommand(cmd);\n} catch (JedisException e) {\n  if (e.getMessage().contains(\"Retry deadline exceeded\")) {\n    throw new ServiceUnavailableException(e);\n  }\n  throw e;\n}","preventionTips":["Health-check the endpoint before heavy workloads","Align maxAttempts and timeout so the deadline is achievable","Watch connection-pool saturation metrics","Tune socketTimeout lower than the overall retry timeout"],"tags":["retry","timeout","connection","standalone"],"backgroundTag":"request-timeout","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"}