Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#9626 closed (fixed)

Bug in Cache when calling has_key

Reported by: anonymous Owned by: nobody
Component: Core (Cache system) Version: 1.0
Severity: Keywords: cache, has_key, KeyError, locmem, del
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

File "/var/django/mydjangoapp/../mydjangoapp/stories/context_processors.py", line 5, in get_cached_num

if not cache.has_key(which):


File "/var/lib/python-support/python2.4/django/core/cache/backends/locmem.py", line 99, in has_key

del self._cache[key]


KeyError: 'authors'

i do not think, its a bug in my code, when django tries to delete a item, for which i am checking if it even exists.

Change History (6)

comment:1 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:2 by Jacob, 15 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:3 by Malcolm Tredinnick, 15 years ago

As far as I can see, this can only be caused by a thread race, since by the time the line of code in question is executed, we know the key was in the cache from a few lines earlier. I'm avoiding that, but this shouldn't be happening in normal operations, since the locmem cache isn't particularly appropriate for user between multiple threads (every other cache backend is better).

comment:4 by Malcolm Tredinnick, 15 years ago

Resolution: fixed
Status: newclosed

(In [9998]) Fixed #9626 -- Fixed a deletion race in the locmem cache.

comment:5 by mrts, 15 years ago

Malcolm, while you are at it, can you please take a look at #9644 as well? It's the same thing, only in a different location.

comment:6 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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