Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#16358 closed Bug (fixed)

cached_db session with memcached forgets big values

Reported by: ccrisan Owned by: Michael Manfre
Component: Core (Cache system) Version: dev
Severity: Normal Keywords: session cache memcached
Cc: ccrisan Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Considering memcached's 1MB limit, putting a value larger than 1MB into a cached_db session will get written to DB but not to cache. However a previous value for the session key already exists in the cache, and thus the session gets restored with previous data from the cache, instead of the new information stored in django_session table, in the DB.
My guess is that the memcached backed should remove the key when not being able to set it to the new value.

Attachments (1)

memcached.py.patch (640 bytes ) - added by ccrisan 13 years ago.
patch for memcached.py that makes the backend clear a key if unable to set it

Download all attachments as: .zip

Change History (10)

comment:1 by ccrisan, 13 years ago

Cc: ccrisan added

comment:2 by Michael Manfre, 13 years ago

Owner: changed from nobody to anonymous
Status: newassigned
Triage Stage: UnreviewedAccepted

by ccrisan, 13 years ago

Attachment: memcached.py.patch added

patch for memcached.py that makes the backend clear a key if unable to set it

comment:3 by ccrisan, 13 years ago

Has patch: set

I've attached a small simple patch for memcached.py. I'm not sure if this is the right thing to to in this case. What should be a cache's behavior in case of failure to set a key, anyways?

comment:4 by Adam Nelson, 13 years ago

Needs tests: set
Patch needs improvement: set
Version: 1.3SVN

comment:5 by Aymeric Augustin, 12 years ago

This makes sense, could you:

  • add a test case in tests/regressiontests/cache/tests.py?
  • generate a single patch from the root of the Django repository (or make a pull request)?

comment:6 by Michael Manfre, 10 years ago

Needs tests: unset
Owner: changed from anonymous to Michael Manfre
Patch needs improvement: unset

Added a test and a pull request.

comment:7 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Michael Manfre <mmanfre@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In bc8abe36ba5508fe788f6d49a26749268d368583:

Fixed #16358 - Made memcache backend delete old value on a failure to set.

Default Memcached configuration allows for a maximum object of 1MB and
will fail to set the key if it is too large. The key will be deleted from
memcached if it fails to be set. This is needed to avoid an issue with
cache_db session backend using the old value stored in memcached, instead
of the newer value stored in the database.

comment:9 by Michael Manfre <mmanfre@…>, 10 years ago

In a305695f28cb15165a19c3871aec878a230a5105:

Merge pull request #3481 from manfre/ticket-16358

Fixed #16358 - Made memcache backend delete old value on a failure to set.

Note: See TracTickets for help on using tickets.
Back to Top