Skip to content

feat: redis add retry logic#34566

Merged
QuantumGhost merged 2 commits intolanggenius:mainfrom
fatelei:issue-34557
Apr 9, 2026
Merged

feat: redis add retry logic#34566
QuantumGhost merged 2 commits intolanggenius:mainfrom
fatelei:issue-34557

Conversation

@fatelei
Copy link
Copy Markdown
Contributor

@fatelei fatelei commented Apr 5, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

fix #34557

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-05 13:21:52.861305891 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-05 13:21:44.172334332 +0000
@@ -305,8 +305,10 @@
    --> core/tools/workflow_as_tool/provider.py:237:26
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
+ERROR Could not import `ExponentialWithJitterBackoff` from `redis.backoff` [missing-module-attribute]
+  --> extensions/ext_redis.py:10:27
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6035,6 +6037,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-05 14:24:20.102420351 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-05 14:24:11.473369173 +0000
@@ -306,7 +306,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6035,6 +6035,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-06 05:24:30.690565737 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-06 05:24:20.919535384 +0000
@@ -306,7 +306,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6035,6 +6035,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 02:01:43.036422731 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 02:01:33.316435669 +0000
@@ -300,7 +300,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6039,6 +6039,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 02:03:49.268275657 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 02:03:40.569295338 +0000
@@ -300,7 +300,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6039,6 +6039,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-08 07:33:41.471432463 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-08 07:33:33.243372697 +0000
@@ -300,7 +300,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6047,6 +6047,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-09 01:35:07.738309085 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-09 01:34:58.664361787 +0000
@@ -298,7 +298,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6055,6 +6055,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-09 01:37:07.008351346 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-09 01:36:58.569298725 +0000
@@ -298,7 +298,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6055,6 +6055,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

Comment thread api/configs/middleware/cache/redis_config.py
Comment thread api/.env.example
Comment thread docker/.env.example
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-09 02:57:50.915323577 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-09 02:57:42.323336094 +0000
@@ -298,7 +298,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6055,6 +6055,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

QuantumGhost
QuantumGhost previously approved these changes Apr 9, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 9, 2026
@QuantumGhost QuantumGhost enabled auto-merge April 9, 2026 02:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-09 03:00:07.942524759 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-09 02:59:59.613516356 +0000
@@ -298,7 +298,7 @@
 ERROR Returned type `dict[object, str]` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
    --> core/workflow/human_input_compat.py:183:16
 ERROR No matching overload found for function `redis.client.Redis.__init__` called with arguments: (connection_pool=ConnectionPool) [no-matching-overload]
-   --> extensions/ext_redis.py:244:38
+   --> extensions/ext_redis.py:282:38
 ERROR Cannot index into `Literal['']` [bad-index]
   --> extensions/storage/huawei_obs_storage.py:27:23
 ERROR Cannot index into `Literal['']` [bad-index]
@@ -6055,6 +6055,8 @@
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:139:20
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:140:20
+ERROR Object of class `Retry` has no attribute `_retries` [missing-attribute]
+  --> tests/unit_tests/extensions/test_redis.py:31:16
 ERROR Argument `dict[str, bytes | str]` is not assignable to parameter `headers` with type `Headers | Mapping[bytes, bytes] | Mapping[str, str] | Sequence[tuple[bytes, bytes]] | Sequence[tuple[str, str]] | None` in function `httpx._models.Response.__init__` [bad-argument-type]
   --> tests/unit_tests/factories/test_build_from_mapping.py:75:21
 ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]

@QuantumGhost QuantumGhost added this pull request to the merge queue Apr 9, 2026
Merged via the queue into langgenius:main with commit 27e484e Apr 9, 2026
28 checks passed
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance Redis HA with client retry and connection health settings

2 participants