Opened 4 years ago

Closed 9 months ago

Last modified 9 months ago

#16358 closed Bug (fixed)

cached_db session with memcached forgets big values

Reported by: ccrisan Owned by: manfre
Component: Core (Cache system) Version: master
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 4 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 Changed 4 years ago by ccrisan

  • Cc ccrisan added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by manfre

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by ccrisan

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

comment:3 Changed 4 years ago by ccrisan

  • 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 Changed 4 years ago by adamnelson

  • Needs tests set
  • Patch needs improvement set
  • Version changed from 1.3 to SVN

comment:5 Changed 2 years ago by aaugustin

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 Changed 9 months ago by manfre

  • Needs tests unset
  • Owner changed from anonymous to manfre
  • Patch needs improvement unset

Added a test and a pull request.

comment:7 Changed 9 months ago by timgraham

  • Triage Stage changed from Accepted to Ready for checkin

comment:8 Changed 9 months ago by Michael Manfre <mmanfre@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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 Changed 9 months ago by Michael Manfre <mmanfre@…>

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