Opened 2 years ago

Last modified 2 years ago

#33681 closed Bug

Redis client OPTIONS don't work as documented, which makes setting Redis timeouts difficult — at Version 3

Reported by: Ben Picolo Owned by: nobody
Component: Core (Cache system) Version: 4.0
Severity: Release blocker Keywords:
Cc: Nick Pope Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ben Picolo)

Hello! First Django interaction, so please let me know how better I can give info here.

I discovered unintentionally that there's no default socket_timeout set for Redis cache connections. This is an issue on it's own (unsafe default that's a particularly hard issue to track down), but in trying to set those timeouts, I hit some tough edges of documentation/usage.

The cache documentation says that the OPTIONS object is passed to the third-party connection class for connections backed by third-party libraries for connections backed by third-party libraries. This is reaffirmed for the redis cache specifically here.

Right now, though, these OPTIONS are passed to the first-party RedisCacheClient object, so you can't pass in options expected by the redis connection pool link. In that sense, RedisCacheClient is being treated as a "first-party" cache according to these docs, but it defers directly to the redis library.

One could do a variety of subclassing to make this work, but there's quite a few layers of indirection here, so it's hard to identify exactly what one should subclass in order to get arguments to the connection class appropriately.

(For now, my workaround is take advantage of the from_url behavior where the connection class pulls arguments out of the connection query string, but this isn't straightforward and feels brittle).

There are a couple of options here – revising documentation or changing behavior (or both).

In my ideal case, it would be great for it to be easy to pass down explicit socket and other timeouts. To me, that suggests updating behavior is ideal, because the documentation would potentially lead folk down a path of tough to navigate behavior.

Change History (3)

comment:1 by Ben Picolo, 2 years ago

Description: modified (diff)

comment:2 by Ben Picolo, 2 years ago

Description: modified (diff)

comment:3 by Ben Picolo, 2 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top