Opened 7 years ago
Closed 7 years ago
#28564 closed Bug (invalid)
Cache backend with python-memcached broken: TypeError: __init__() got an unexpected keyword argument 'KEY_PREFIX'
Reported by: | Thomas Bechtold | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using django-1.11 together with python-memcached-1.58 on SLES12SP3.
The cache backend is configured with:
CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': [ '192.168.249.81:11211', ], 'OPTIONS': { 'KEY_PREFIX': 'horizon-config-default' } } }
Accessing the auth/login url leads now to:
[Mon Sep 04 05:47:58.616177 2017] [wsgi:error] [pid 13501] Internal Server Error: /auth/login/ [Mon Sep 04 05:47:58.616189 2017] [wsgi:error] [pid 13501] Traceback (most recent call last): [Mon Sep 04 05:47:58.616192 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner [Mon Sep 04 05:47:58.616194 2017] [wsgi:error] [pid 13501] response = get_response(request) [Mon Sep 04 05:47:58.616197 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response [Mon Sep 04 05:47:58.616199 2017] [wsgi:error] [pid 13501] response = self._get_response(request) [Mon Sep 04 05:47:58.616201 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in _get_response [Mon Sep 04 05:47:58.616203 2017] [wsgi:error] [pid 13501] response = self.process_exception_by_middleware(e, request) [Mon Sep 04 05:47:58.616214 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 215, in _get_response [Mon Sep 04 05:47:58.616216 2017] [wsgi:error] [pid 13501] response = response.render() [Mon Sep 04 05:47:58.616218 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/response.py", line 107, in render [Mon Sep 04 05:47:58.616220 2017] [wsgi:error] [pid 13501] self.content = self.rendered_content [Mon Sep 04 05:47:58.616222 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/response.py", line 84, in rendered_content [Mon Sep 04 05:47:58.616224 2017] [wsgi:error] [pid 13501] content = template.render(context, self._request) [Mon Sep 04 05:47:58.616226 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render [Mon Sep 04 05:47:58.616238 2017] [wsgi:error] [pid 13501] return self.template.render(context) [Mon Sep 04 05:47:58.616240 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 207, in render [Mon Sep 04 05:47:58.616242 2017] [wsgi:error] [pid 13501] return self._render(context) [Mon Sep 04 05:47:58.616244 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render [Mon Sep 04 05:47:58.616245 2017] [wsgi:error] [pid 13501] return self.nodelist.render(context) [Mon Sep 04 05:47:58.616247 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render [Mon Sep 04 05:47:58.616249 2017] [wsgi:error] [pid 13501] bit = node.render_annotated(context) [Mon Sep 04 05:47:58.616251 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated [Mon Sep 04 05:47:58.616252 2017] [wsgi:error] [pid 13501] return self.render(context) [Mon Sep 04 05:47:58.616254 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render [Mon Sep 04 05:47:58.616256 2017] [wsgi:error] [pid 13501] return compiled_parent._render(context) [Mon Sep 04 05:47:58.616258 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render [Mon Sep 04 05:47:58.616259 2017] [wsgi:error] [pid 13501] return self.nodelist.render(context) [Mon Sep 04 05:47:58.616261 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render [Mon Sep 04 05:47:58.616263 2017] [wsgi:error] [pid 13501] bit = node.render_annotated(context) [Mon Sep 04 05:47:58.616265 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated [Mon Sep 04 05:47:58.616266 2017] [wsgi:error] [pid 13501] return self.render(context) [Mon Sep 04 05:47:58.616268 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render [Mon Sep 04 05:47:58.616270 2017] [wsgi:error] [pid 13501] result = block.nodelist.render(context) [Mon Sep 04 05:47:58.616272 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render [Mon Sep 04 05:47:58.616285 2017] [wsgi:error] [pid 13501] bit = node.render_annotated(context) [Mon Sep 04 05:47:58.616287 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated [Mon Sep 04 05:47:58.616289 2017] [wsgi:error] [pid 13501] return self.render(context) [Mon Sep 04 05:47:58.616290 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render [Mon Sep 04 05:47:58.616292 2017] [wsgi:error] [pid 13501] return template.render(context) [Mon Sep 04 05:47:58.616296 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 209, in render [Mon Sep 04 05:47:58.616298 2017] [wsgi:error] [pid 13501] return self._render(context) [Mon Sep 04 05:47:58.616300 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 199, in _render [Mon Sep 04 05:47:58.616302 2017] [wsgi:error] [pid 13501] return self.nodelist.render(context) [Mon Sep 04 05:47:58.616304 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 990, in render [Mon Sep 04 05:47:58.616305 2017] [wsgi:error] [pid 13501] bit = node.render_annotated(context) [Mon Sep 04 05:47:58.616307 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated [Mon Sep 04 05:47:58.616309 2017] [wsgi:error] [pid 13501] return self.render(context) [Mon Sep 04 05:47:58.616311 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 127, in render [Mon Sep 04 05:47:58.616313 2017] [wsgi:error] [pid 13501] return self.render_compressed(context, self.kind, self.mode, forced=forced) [Mon Sep 04 05:47:58.616315 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 99, in render_compressed [Mon Sep 04 05:47:58.616317 2017] [wsgi:error] [pid 13501] cache_key, cache_content = self.render_cached(compressor, kind, mode) [Mon Sep 04 05:47:58.616318 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 78, in render_cached [Mon Sep 04 05:47:58.616320 2017] [wsgi:error] [pid 13501] cache_key = get_templatetag_cachekey(compressor, mode, kind) [Mon Sep 04 05:47:58.616322 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/cache.py", line 94, in get_templatetag_cachekey [Mon Sep 04 05:47:58.616324 2017] [wsgi:error] [pid 13501] "templatetag.%s.%s.%s" % (compressor.cachekey, mode, kind)) [Mon Sep 04 05:47:58.616326 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/utils/decorators.py", line 39, in __get__ [Mon Sep 04 05:47:58.616328 2017] [wsgi:error] [pid 13501] value = obj.__dict__[self.__name__] = self.__get(obj) [Mon Sep 04 05:47:58.616329 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/base.py", line 176, in cachekey [Mon Sep 04 05:47:58.616331 2017] [wsgi:error] [pid 13501] [self.content] + self.mtimes).encode(self.charset), 12) [Mon Sep 04 05:47:58.616333 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/utils/decorators.py", line 39, in __get__ [Mon Sep 04 05:47:58.616335 2017] [wsgi:error] [pid 13501] value = obj.__dict__[self.__name__] = self.__get(obj) [Mon Sep 04 05:47:58.616337 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/base.py", line 171, in mtimes [Mon Sep 04 05:47:58.616339 2017] [wsgi:error] [pid 13501] if kind == SOURCE_FILE] [Mon Sep 04 05:47:58.616340 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/compressor/cache.py", line 100, in get_mtime [Mon Sep 04 05:47:58.616342 2017] [wsgi:error] [pid 13501] mtime = cache.get(key) [Mon Sep 04 05:47:58.616344 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 79, in get [Mon Sep 04 05:47:58.616346 2017] [wsgi:error] [pid 13501] val = self._cache.get(key) [Mon Sep 04 05:47:58.616348 2017] [wsgi:error] [pid 13501] File "/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 173, in _cache [Mon Sep 04 05:47:58.616349 2017] [wsgi:error] [pid 13501] self._client = self._lib.Client(self._servers, **client_kwargs) [Mon Sep 04 05:47:58.616351 2017] [wsgi:error] [pid 13501] TypeError: __init__() got an unexpected keyword argument 'KEY_PREFIX' [Mon Sep 04 05:47:59.236287 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] mod_wsgi (pid=13501): Exception occurred processing WSGI script '/srv/www/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'. [Mon Sep 04 05:47:59.236308 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] Traceback (most recent call last): [Mon Sep 04 05:47:59.236327 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] File "/usr/lib/python2.7/site-packages/django/http/response.py", line 264, in close [Mon Sep 04 05:47:59.236479 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] signals.request_finished.send(sender=self._handler_class) [Mon Sep 04 05:47:59.236494 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] File "/usr/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send [Mon Sep 04 05:47:59.236574 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] for receiver in self._live_receivers(sender) [Mon Sep 04 05:47:59.236586 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] File "/usr/lib/python2.7/site-packages/django/core/cache/__init__.py", line 125, in close_caches [Mon Sep 04 05:47:59.236632 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] cache.close() [Mon Sep 04 05:47:59.236640 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] File "/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 107, in close [Mon Sep 04 05:47:59.236655 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] self._cache.disconnect_all() [Mon Sep 04 05:47:59.236660 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] File "/usr/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 173, in _cache [Mon Sep 04 05:47:59.236669 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] self._client = self._lib.Client(self._servers, **client_kwargs) [Mon Sep 04 05:47:59.236684 2017] [wsgi:error] [pid 13501] [remote 10.163.0.83:34805] TypeError: __init__() got an unexpected keyword argument 'KEY_PREFIX'
The problem was introduced by commit https://github.com/django/django/commit/65ec8fa8ca56a5378345375e1079025c96d0b833
Note:
See TracTickets
for help on using tickets.
The cache is wrongly configured.
KEY_PREFIX
should be outside of the OPTIONS dict.