Opened 8 years ago

Closed 7 years ago

Last modified 5 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: UI/UX:


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

if not cache.has_key(which):

File "/var/lib/python-support/python2.4/django/core/cache/backends/", 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 Changed 8 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:2 Changed 7 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by mtredinnick

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 Changed 7 years ago by mtredinnick

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

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

comment:5 Changed 7 years ago by mrts

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 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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