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:
@@ -160,7 +160,7 @@ PostgreSQL (change `postgres-storage`), вход и Bearer-сессии — chan
|
||||
| `service-layer.md` | `src/core/services/**` |
|
||||
| `repo-layer.md` | `src/core/repos/**` |
|
||||
| `dto.md` | `src/schemas/**` |
|
||||
| `infra.md` | `src/infra/**`: логгер, PostgreSQL (engine, пул, таймауты), readiness, кэш Valkey (без повторов, обход при отказе) и другие клиенты |
|
||||
| `infra.md` | `src/infra/**`: логгер, PostgreSQL (engine, пул, таймауты), readiness, кэш Valkey (повтор только на обрыв, срок на команду, обход при отказе) и другие клиенты |
|
||||
| `auth.md` | `src/**/session.py`, сервис пользователей, `dependencies.py`, `errors.py`, идентификация в `student-tests/`: пароль и KDF, разбор Basic, токен, срок и отзыв сессии |
|
||||
| `logging.md` | сервисы, API, инфраструктура, `src/main.py`: где и как логировать, чего в логах быть не должно |
|
||||
| `settings.md` | `src/config/**`, `.env.example`, `config_example.toml`: источники настроек, что куда класть |
|
||||
@@ -300,7 +300,7 @@ src/
|
||||
db/session.py # глобалы engine и session_factory процесса API
|
||||
db/errors.py # is_db_unavailable: какие ошибки драйвера — 503
|
||||
db/models/ # модели SQLAlchemy (Base с created_at и to_dict)
|
||||
cache/client.py # create_cache (redis-py без повторов, блокирующий пул), Cache: отказ — промах и пропуск
|
||||
cache/client.py # create_cache (redis-py: повтор только на обрыв, блокирующий пул), Cache: срок на команду, отказ — промах и пропуск
|
||||
cache/instance.py # глобал cache процесса API
|
||||
schemas/
|
||||
dataclasses/<domain>.py # DTO между repo → service → api
|
||||
|
||||
Reference in New Issue
Block a user