#35651: RedisCacheClient does not reuse connections from the connection pool
-------------------------------------+-------------------------------------
Reporter: gojuukaze | Owner: Ankit
| Jhunjhunwala
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* cc: Jon Janzen (added)
* needs_better_patch: 0 => 1
Comment:
Copying
[
https://github.com/django/django/pull/18459#pullrequestreview-2276655971
my comment from the PR], because I don't think the approach suggested
there is viable:
> I haven't had the chance to fully dig in and see what/why it's happening
but logging in BaseConnectionHandler.__getitem__() shows that we're not
correctly caching the connection instance. The expected behaviour there is
to create the instance on the first access, and then re-use it. That's not
happening.
>
> For some value of works, moving the pools to the class will work around
it, but not for the correct reason, AFAICS.
>
> The reproduce uses ASGI. Q: is this only happening in async code? I'm
imagining so because the connections storage is a Local, so we'll be
running into some thread sensitivity issue here: self._connections =
Local(self.thread_critical)
>
> More investigation needed.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35651#comment:14>