question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

invalidate_cms_page_cache() prevents start, if db cachetable is non existent

See original GitHub issue

Precondition: Django CMS App, working, without any Caching.

  1. Add simple db cache to settings.py
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'my_cache_table',
    }
}

  1. 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:

  1. remove all non basic django.* modules from INSTALLED_APPS
  2. run manage.py createcachetable
  3. 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:open
  • Created 8 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
julianandrewscommented, Mar 17, 2017

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.

0reactions
ipmbcommented, Mar 31, 2022

#7269 may provide a workaround for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

UNCACHE TABLE - Spark 3.3.1 Documentation
UNCACHE TABLE removes the entries and associated data from the in-memory and/or on-disk cache for a given table or view. The underlying entries...
Read more >
UNCACHE TABLE | Databricks on AWS
UNCACHE TABLE on a non-existent table throws an exception if IF EXISTS is not specified. In this article: Syntax; Parameters; Examples; Related ...
Read more >
Django's cache framework
A final point about Memcached is that memory-based caching has a disadvantage: because the cached data is stored in memory, the data will...
Read more >
UNCACHE TABLE - Azure Databricks - Microsoft Learn
UNCACHE TABLE on a non-existent table throws an exception if IF EXISTS is not specified. Syntax. Copy. UNCACHE TABLE [ IF EXISTS ] ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found