Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 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:

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.

Attachments (0)

Change History (6)

comment:1 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:2 Changed 5 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 5 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 5 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 5 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 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.