Menu

1 / 2

Redis retry_on_timeout=False Still Counted My INCR Twice

DEV Community: redis·Ace Meridian·about 5 hours ago
#W837RhNL
#devtoredis#devto#dev#retry#redis
Reading 0:00
15s threshold

In redis-py 8.1.0, retry_on_timeout=False does not turn retries off: every client retries up to 10 times on TimeoutError by default, so one INCR that hit a 0.5 s socket timeout returned 2 and left the counter at 2. For writes that must not run twice, give the client retry=Retry(NoBackoff(), 0) or make the write idempotent with a request ID, because even without a retry a timeout only means "maybe applied".

This story was written with the assistance of an AI writing program. The numbers below come from a local Redis 8.10.2 server and redis-py 8.1.0 on Python 3.14.4; the stall tests ran twice, and no shared instance was involved.

The flag that stopped doing anything

Plenty of Redis clients were written as redis.Redis(host=..., socket_timeout=0.5, retry_on_timeout=False) by people who wanted a fast failure instead of a retry.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.