invalidate_cms_page_cache() prevents start, if db cachetable is non existent
See original GitHub issuePrecondition: Django CMS App, working, without any Caching.
- Add simple db cache to settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'my_cache_table',
}
}
- run manage.py createcachetable
This will result in the error shown in the stacktrace below.
CMS tries to invalidate the cache before the cachetable could be created.
As a workaround it is necessary to:
- remove all non basic django.* modules from INSTALLED_APPS
- run manage.py createcachetable
- readd all the modules again
Stack Trace:
./manage.py createcachetable /usr/local/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9. return f(_args, *_kwds)
/usr/local/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes. return f(_args, *_kwds)
Traceback (most recent call last): File “/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py”, line 64, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: FEHLER: Relation „db_cache_table“ existiert nicht LINE 1: SELECT cache_key, value, expires FROM “db_cache_table” WHERE… ^
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File “./manage.py”, line 10, in <module> execute_from_command_line(sys.argv) File “/usr/local/lib/python3.4/site-packages/django/core/management/init.py”, line 351, in execute_from_command_line utility.execute() File “/usr/local/lib/python3.4/site-packages/django/core/management/init.py”, line 325, in execute django.setup() File “/usr/local/lib/python3.4/site-packages/django/init.py”, line 18, in setup apps.populate(settings.INSTALLED_APPS) File “/usr/local/lib/python3.4/site-packages/django/apps/registry.py”, line 115, in populate app_config.ready() File “/usr/local/lib/python3.4/site-packages/django/contrib/admin/apps.py”, line 22, in ready self.module.autodiscover() File “/usr/local/lib/python3.4/site-packages/django/contrib/admin/init.py”, line 24, in autodiscover autodiscover_modules(‘admin’, register_to=site) File “/usr/local/lib/python3.4/site-packages/django/utils/module_loading.py”, line 74, in autodiscover_modules import_module(‘%s.%s’ % (app_config.name, module_to_search)) File “/usr/local/lib/python3.4/importlib/init.py”, line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File “<frozen importlib._bootstrap>”, line 2254, in _gcd_import File “<frozen importlib._bootstrap>”, line 2237, in _find_and_load File “<frozen importlib._bootstrap>”, line 2226, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 1200, in _load_unlocked File “<frozen importlib._bootstrap>”, line 1129, in _exec File “<frozen importlib._bootstrap>”, line 1471, in exec_module File “<frozen importlib._bootstrap>”, line 321, in _call_with_frames_removed File “/usr/local/lib/python3.4/site-packages/cms/admin/init.py”, line 11, in <module> plugin_pool.plugin_pool.discover_plugins() File “/usr/local/lib/python3.4/site-packages/cms/plugin_pool.py”, line 32, in discover_plugins invalidate_cms_page_cache() File “/usr/local/lib/python3.4/site-packages/cms/cache/init.py”, line 69, in invalidate_cms_page_cache version = _get_cache_version() File “/usr/local/lib/python3.4/site-packages/cms/cache/init.py”, line 15, in _get_cache_version version = cache.get(CMS_PAGE_CACHE_VERSION_KEY) File “/usr/local/lib/python3.4/site-packages/django/core/cache/backends/db.py”, line 66, in get “WHERE cache_key = %%s” % table, [key]) File “/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py”, line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File “/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py”, line 64, in execute return self.cursor.execute(sql, params) File “/usr/local/lib/python3.4/site-packages/django/db/utils.py”, line 97, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File “/usr/local/lib/python3.4/site-packages/django/utils/six.py”, line 658, in reraise raise value.with_traceback(tb) File “/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py”, line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: FEHLER: Relation „db_cache_table“ existiert nicht LINE 1: SELECT cache_key, value, expires FROM “db_cache_table” WHERE…
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top GitHub Comments
I’m just posting here to note that the correct solution to this bug (and related bugs) is almost certainly to delay hitting the cache until after app load. There are a number of reasons that hitting the cache too early is a bad idea.
#7269 may provide a workaround for this