[Django] #34806: Make cached_db backend resilient to cache backend errors

17 views
Skip to first unread message

Django

unread,
Aug 31, 2023, 12:17:43 PM8/31/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
--------------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: contrib.sessions | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
In the case storing the session data in the cache for the `cached_db`
backend is failing, this should not make the whole request crash.

Use case: you add a big content to `messages.success`, bigger than what
your configured cache backend can accept (e.g. obtaining a TooBig error
with memcache). Then every future request from that session will crash.

I would suggest to log the failure instead of letting the cache backend
exception crash the request, and continue with the request, as missing
saving the session data in the cache is not a serious condition, it will
only slow the requests a bit as the database will be hit each time until
the issue is solved.

--
Ticket URL: <https://code.djangoproject.com/ticket/34806>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 31, 2023, 4:18:11 PM8/31/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
--------------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Natalia Bidart):

* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Thanks Claude for the report.

Following the description, I agree that it makes sense to not fail the
whole request when the storing in the cache fails. I couldn't find an
older ticket for this issue, so I'm accepting it, though it would be great
if you could provide a reproducer or test case to aid future contributors.

--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:1>

Django

unread,
Sep 1, 2023, 4:16:37 PM9/1/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned

Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sulabh Katila):

* owner: nobody => Sulabh Katila
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:2>

Django

unread,
Sep 2, 2023, 11:32:36 PM9/2/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:3>

Django

unread,
Sep 23, 2023, 4:29:59 PM9/23/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sulabh Katila):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:4>

Django

unread,
Sep 24, 2023, 5:37:32 AM9/24/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:5>

Django

unread,
Oct 31, 2023, 2:21:58 PM10/31/23
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Natalia Bidart):

Replied to PR questions and made an initial review, left comments.

--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:6>

Django

unread,
Jan 16, 2024, 10:28:37 AM1/16/24
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sulabh Katila):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:7>

Django

unread,
Feb 19, 2024, 3:49:35 PM2/19/24
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sulabh Katila):

* needs_docs: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:8>

Django

unread,
Feb 21, 2024, 12:55:04 PM2/21/24
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: assigned
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:9>

Django

unread,
Feb 21, 2024, 7:52:08 PM2/21/24
to django-...@googlegroups.com
#34806: Make cached_db backend resilient to cache backend errors
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Sulabh
Type: | Katila
Cleanup/optimization | Status: closed
Component: contrib.sessions | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"eceb5e2eea554ea0f9baf7abc1b1972459854cef" eceb5e2]:
{{{#!CommitTicketReference repository=""
revision="eceb5e2eea554ea0f9baf7abc1b1972459854cef"
Fixed #34806 -- Made cached_db session backend resilient to cache write
errors.

Co-authored-by: Natalia <124304+...@users.noreply.github.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34806#comment:10>
Reply all
Reply to author
Forward
0 new messages