fix: retry Valkey once on a dropped connection

The client passed the sync redis.retry.Retry to async connections, so no
retry could ever run. Use redis.asyncio.retry.Retry with one immediate
retry on ConnectionError only: after a Valkey restart the stale pooled
connection is reopened instead of switching the cache off for 5 s.
Timeouts are not retried, and asyncio.timeout bounds each cache command
(pool wait, connect, retry, reply) by [cache] timeout_seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 21:41:15 +03:00
co-authored by Claude Opus 5.5
parent 25a60d36cd
commit d7c9a5972b
7 changed files with 99 additions and 41 deletions
+19 -1
View File
@@ -43,7 +43,8 @@
## 3. Код
- [x] 3.1 `src/infra/cache/`: фабрика клиента без повторов, обёртка
- [x] 3.1 `src/infra/cache/`: фабрика клиента без повторов (после
verify — один повтор на обрыв, задача 7.1), обёртка
`Cache` с пропуском после отказа и журналом, глобал в `instance.py`
(решения 4, 5). Проверка: разовым скриптом против Valkey стенда
`set`/`get` работают; при `docker compose stop valkey` `get`
@@ -111,3 +112,20 @@
- [x] 6.3 `make lint`, `make check`, `openspec validate membership-cache
--strict`, `graphify update .`; показать изменения и после
подтверждения закоммитить evidence и отчёт.
## 7. Правки по verify
- [x] 7.1 Клиент (решение 4): `Retry` из `redis.asyncio.retry` — один
немедленный повтор только на `ConnectionError`; вся команда `Cache` —
под `asyncio.timeout([cache] timeout_seconds)`. Проверка: разовым
скриптом против Valkey стенда — после `restart valkey` промах без
`warning`, `stop` — < 50 мс, `pause` — ≈ 0,2 с, 30 одновременных
команд при `pause` — не дольше 0,21 с; `driver.py all` — код 0.
- [x] 7.2 Документы под новое поведение: design (Context, решения 4–5,
Risks), `infra.md`, `AGENTS.md`, комментарии `[cache] timeout_seconds`,
`REPORT.md`. Проверка: `grep -rn "без повторов" .claude AGENTS.md
REPORT.md` — нет утверждений, что повторов нет совсем.
- [ ] 7.3 `make lint`, `make test_isolated`; после подтверждения —
commit фикса. Затем с него переснять `evidence/cache/outage.md` и
`evidence/cache/flush-restart.md`, обновить строки `REPORT.md` и после
подтверждения закоммитить.