Code

Opened 3 years ago

Closed 13 months ago

#15729 closed Bug (needsinfo)

Cache middleware issues after restart when using mod_wsgi with PyLibMC

Reported by: jsdalton Owned by: nobody
Component: Core (Cache system) Version: 1.3
Severity: Normal Keywords:
Cc: oliver@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm running into a cache error using the PyLibMC cache backend in conjunction with mod_wsgi.

I have a strong feeling it's related to #15655 and is probably an issue for the pylibmc maintainers and not Django. I do feel, however, that the issue is worth reporting here because it is occurring on a pretty standard installation with the recommended web server (mod_wsgi). It also makes me wonder whether more robust error handling might need to be built into the PyLibMC backend to account for ways things could go wrong.

So, the gist of the problem: I have memcached running on a separate server and PyLibMC as the memcached backend. Things work great...until I restart memcached. After doing so I get the following traceback:

Traceback (most recent call last):

File "/var/www/****/src/django/django/core/handlers/base.py", line 89, in get_response
  response = middleware_method(request)
File "/var/www/*****/src/django/django/middleware/cache.py", line 143, in process_request
  cache_key = get_cache_key(request, self.key_prefix, 'GET', cache=self.cache)
File "/var/www/*****/src/django/django/utils/cache.py", line 190, in get_cache_key
  headerlist = cache.get(cache_key, None)
File "/var/www/*****/src/django/django/core/cache/backends/memcached.py", line 58, in get
  val = self._cache.get(key)
UnknownReadFailure: error 7 from memcached_get: UNKNOWN READ FAILURE

Restarting Apache resolved this error.

The issue does not occur when using MemcachedCache backend.

Attachments (0)

Change History (7)

comment:1 Changed 3 years ago by lukeplant

  • Type set to Bug

comment:2 Changed 3 years ago by lukeplant

  • Severity set to Normal

comment:3 follow-up: Changed 3 years ago by toxik

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

It's actually not even a fault pylibmc can handle - the underlying libmemcached library should be handling this. There are patches floating around the internet regarding libmemcached's handling of failures but I would suggest pushing for this issue on the libmemcached mailing list.

Version 0, edited 3 years ago by toxik (next)

comment:4 in reply to: ↑ 3 Changed 3 years ago by jsdalton

Replying to toxik:

It's actually not even a fault pylibmc can handle - the underlying libmemcached library should be handling this. There are patches floating around the internet regarding libmemcached's handling of failures but I would suggest pushing for this issue on the libmemcached mailing list.

Yeah, I don't know. I guess I just feel like if you're deploying on a stack that's "recommended" by the official Django documentation and a failry typical action within that stack (restarting memcached service) causes an application error within Django that literally brings your application to a halt, then that's perhaps something that should at least be mentioned in the documentation? I mean, I saw the addition of PyLibMC and had heard good things about it, and went through the trouble of configuring and deploying it, and only very fortunately caught the issue while it was still staging so that it did not make it production. It seems like a huge red flag to using the library.

But I completely understand your line of reasoning. It's not something it would appear Django can do anything about directly, but by the same token should that library be supported?

comment:5 Changed 3 years ago by jacob

  • Easy pickings unset
  • Triage Stage changed from Unreviewed to Design decision needed

Is it possible for us to work around this in a non-nasty way? Otherwise I think we just have to document it and hope the pylibmc/libmemcached folks fix their stuff.

comment:6 Changed 3 years ago by obeattie

  • Cc oliver@… added
  • UI/UX unset

Has it actually been brought to the attention of the pylibmc/libmemcached folks?

comment:7 Changed 13 months ago by aaugustin

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

There's more questions than answers on this ticket... If you want to advance this bug, get feedback from the pylibmc maintainers, and suggest a workaround.

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.