2347: Cache backend UI in admin settings is error-prone and can break access to site.

netzh*****@gmai***** (Google Code) (Is this you? Claim this profile.)
david
david
Jan. 24, 2012
What version are you running?
1.6.1

What's the URL of the page containing the problem?
http://*/admin

What steps will reproduce the problem?
1. at first, I install with memcached. Later, I disable it in the admin dashboard by delete memcached://localhost:11211/ directly. 
2. Then I cannot use the http://*/admin any more
3.

What is the expected output? What do you see instead?
I should see the admin settings.

What operating system are you using? What browser?
Amazon EC2, Amazon OS

Please provide any additional information below.

Environment:


Request Method: GET
Request URL: http://11.11.1.1:10001/admin/

Django Version: 1.3.1
Python Version: 2.6.7
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.markup',
 'django.contrib.sites',
 'django.contrib.sessions',
 'djblets.datagrid',
 'djblets.feedview',
 'djblets.gravatars',
 'djblets.log',
 'djblets.siteconfig',
 'djblets.util',
 'djblets.webapi',
 'reviewboard.accounts',
 'reviewboard.admin',
 'reviewboard.attachments',
 'reviewboard.changedescs',
 'reviewboard.diffviewer',
 'reviewboard.notifications',
 'reviewboard.reports',
 'reviewboard.reviews',
 'reviewboard.scmtools',
 'reviewboard.site',
 'reviewboard.webapi',
 'django_evolution']
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.http.ConditionalGetMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'djblets.siteconfig.middleware.SettingsMiddleware',
 'reviewboard.admin.middleware.LoadSettingsMiddleware',
 'djblets.log.middleware.LoggingMiddleware',
 'reviewboard.admin.middleware.CheckUpdatesRequiredMiddleware',
 'reviewboard.admin.middleware.X509AuthMiddleware',
 'reviewboard.site.middleware.LocalSiteMiddleware')


Traceback:
File "/usr/lib/python2.6/site-packages/Django-1.3.1-py2.6.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/Django-1.3.1-py2.6.egg/django/contrib/admin/views/decorators.py" in _checklogin
  19.             return view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/ReviewBoard-1.6.1-py2.6.egg/reviewboard/admin/views.py" in dashboard
  33.         'has_cache_stats': get_has_cache_stats(),
File "/usr/lib/python2.6/site-packages/ReviewBoard-1.6.1-py2.6.egg/reviewboard/admin/cache_stats.py" in get_has_cache_stats
  34.     return get_memcached_hosts() != None
File "/usr/lib/python2.6/site-packages/ReviewBoard-1.6.1-py2.6.egg/reviewboard/admin/cache_stats.py" in get_memcached_hosts
  22.     scheme, host, params = parse_backend_uri(settings.CACHE_BACKEND)
File "/usr/lib/python2.6/site-packages/Django-1.3.1-py2.6.egg/django/core/cache/__init__.py" in parse_backend_uri
  60.         raise InvalidCacheBackendError("Backend URI must start with scheme://")

Exception Type: InvalidCacheBackendError at /admin/
Exception Value: Backend URI must start with scheme://
david
#1 david
In order to fix this, you'll have to go through and update your database by hand.

We should fix this UI to be less error-prone.
  • +Cache backend UI in admin settings is error-prone and can break access to site.
david
#2 david
  • +Started
  • +Component-Admin
  • +david
david
#3 david
Fixed in release-1.6.x (d904929). Thanks!
  • -Started
    +Fixed
#4 pierre.etie***********@gmai***** (Google Code) (Is this you? Claim this profile.)
I am getting the same error (I use a release prior to this fix). What needs to be changed in the database in order to recover from this state? Thanks
chipx86
#5 chipx86
If you can reach the General Settings page, then you should be able to change the URI there. Otherwise, if it's that old a version now, you'll need to do the following:

$ rb-site manage /path/to/site shell
>>> from djblets.siteconfig.models import SiteConfiguration
>>> siteconfig = SiteConfiguration.objects.get_current()
>>> siteconfig.set('cache_backend', '<proper Django cache backend URI>')
>>> siteconfig.save()
#6 pierre.etie***********@gmai***** (Google Code) (Is this you? Claim this profile.)
Meanwhile, I tried to upgrade my 1.7RCsomething version to latest 1.7.6 yesterday.

I cannot get into the General Settings page. Current error is:

KeyError at /rb/admin/
Request Method:	GET
Request URL:	http://192.168.0.5/rb/admin/
Django Version:	1.4.5
Exception Type:	KeyError
Exception Value: 'BACKEND'


Shall I try the rb-site thing or is it too risky?

One strange thing is that in the Error log, it shows (notice the empty 'default'):
CACHES	
{'default': {},
 'staticfiles': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                 'LOCATION': 'staticfiles-filehashes'}}

While my settings_local.py has:
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    },
}


Thanks!