[Django] #22495: Locmem cache.add() fails with infinitely cached objects

16 views
Skip to first unread message

Django

unread,
Apr 23, 2014, 6:49:23 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+--------------------
Reporter: boxm | Owner: nobody
Type: Bug | Status: new
Component: Core (Cache system) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+--------------------
Simple test case:

{{{
from django.core.cache.backends.locmem import LocMemCache

c2 = LocMemCache("locmem", {})

In [18]: c2.set('test', 'locked', timeout=None)

In [19]: c2.add('test', 'new')
Out[19]: True

In [20]: c2.get('test')
Out[20]: 'new'
}}}

Since a timeout of None now means "cache forever", the cache.add() should
not succeed and should return False.

Memcached behaviour for comparison:

{{{
In [24]: from django.core.cache.backends.memcached import PyLibMCCache

In [25]: memcache = PyLibMCCache(server="localhost:11211", params={})

In [26]: memcache.set('test', 'locked', timeout=None)

In [27]: memcache.add('test', 'new')
Out[27]: False
}}}

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

Django

unread,
Apr 23, 2014, 7:04:34 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: assigned

Component: Core (Cache system) | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by boxm):

* owner: nobody => boxm
* needs_better_patch: => 0
* status: new => assigned
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Apr 23, 2014, 7:09:12 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by boxm):

Testcase and fix available here:
https://github.com/mbox/django/tree/ticket_22495

Pull request: https://github.com/django/django/pull/2603

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

Django

unread,
Apr 23, 2014, 7:09:35 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 1 | Unreviewed

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

* has_patch: 0 => 1


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

Django

unread,
Apr 23, 2014, 7:41:45 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: assigned
Component: Core (Cache system) | Version:
Severity: Normal | 1.7-beta-2
Keywords: | Resolution:
Has patch: 1 | Triage Stage: Accepted

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

* version: 1.6 => 1.7-beta-2
* stage: Unreviewed => Accepted


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

Django

unread,
Apr 23, 2014, 8:59:15 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: closed

Component: Core (Cache system) | Version:
Severity: Normal | 1.7-beta-2
Keywords: | Resolution: fixed

Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

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


Comment:

In [changeset:"af5f688392b7fc110d06660ff91f79c742ae751d"]:
{{{
#!CommitTicketReference repository=""
revision="af5f688392b7fc110d06660ff91f79c742ae751d"
Fixed #22495 -- Locmem cache.add() failed with infinite timeouts

cache.add() incorrectly succeeded when there was an existing key
with an infinite (None) timeout.
}}}

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

Django

unread,
Apr 23, 2014, 8:59:49 AM4/23/14
to django-...@googlegroups.com
#22495: Locmem cache.add() fails with infinitely cached objects
-------------------------------------+-------------------------------------
Reporter: boxm | Owner: boxm
Type: Bug | Status: closed
Component: Core (Cache system) | Version:
Severity: Normal | 1.7-beta-2
Keywords: | Resolution: fixed
Has patch: 1 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"07235aec9d0853b4fa58629c572912786b6270c9"]:
{{{
#!CommitTicketReference repository=""
revision="07235aec9d0853b4fa58629c572912786b6270c9"
[1.7.x] Fixed #22495 -- Locmem cache.add() failed with infinite timeouts

cache.add() incorrectly succeeded when there was an existing key
with an infinite (None) timeout.

Backport of af5f688392 from master.
}}}

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

Reply all
Reply to author
Forward
0 new messages