#31654: Memcached key validation raises InvalidCacheKey with clunky message.
-------------------------------------+------------------------------------
Reporter: Tim McCormack | Owner: felixxm
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 2.2
Severity: Normal | Resolution:
Keywords: memcached | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Comment (by Tim McCormack):
Ah, this was actually against the dummy backend. It was caught in tests:
https://build.testeng.edx.org/job/edx-platform-python-pipeline-
pr/18276/testReport/junit/common.djangoapps.xblock_django.tests.test_api/XBlockSupportTestCase/Run_Tests___lms_unit___test_disabled_blocks/
{{{
self = <xblock_django.tests.test_api.XBlockSupportTestCase
testMethod=test_disabled_blocks>
def setUp(self):
super(XBlockSupportTestCase, self).setUp()
# Set up XBlockConfigurations for disabled and deprecated states
block_config = [
("poll", True, True),
("survey", False, True),
("done", True, False),
]
for name, enabled, deprecated in block_config:
> XBlockConfiguration(name=name, enabled=enabled,
deprecated=deprecated).save()
common/djangoapps/xblock_django/tests/test_api.py:28:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/config_models/models.py:110: in save
update_fields
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/db/models/base.py:741: in save
force_update=force_update, update_fields=update_fields)
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/db/models/base.py:790: in save_base
update_fields=update_fields, raw=raw, using=using,
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/dispatch/dispatcher.py:175: in send
for receiver in self._live_receivers(sender)
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/dispatch/dispatcher.py:175: in <listcomp>
for receiver in self._live_receivers(sender)
openedx/core/lib/cache_utils.py:187: in invalidate
TieredCache.delete_all_tiers(key)
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/edx_django_utils/cache/utils.py:226: in delete_all_tiers
django_cache.delete(key)
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/core/cache/backends/dummy.py:30: in delete
self.validate_key(key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _
self = <django.core.cache.backends.dummy.DummyCache object at
0x7fc3211f7d30>
key = ":1:<class
'xblock_django.models.XBlockConfiguration'>.xblock_django.api.deprecated_xblocks"
def validate_key(self, key):
"""
Warn about keys that would not be portable to the memcached
backend. This encourages (but does not force) writing backend-
portable
cache code.
"""
for warning in memcache_key_warnings(key):
> warnings.warn(warning, CacheKeyWarning)
E TypeError: 'type' object cannot be interpreted as an integer
../edx-venv-3.5/edx-venv/lib/python3.5/site-
packages/django/core/cache/backends/base.py:250: TypeError
}}}
This error only started happening in tests with the Django 2.2.12 ->
2.2.13 upgrade. I don't understand why we wouldn't have seen the
InvalidCacheKey error in production, where we use memcached.
(We were in fact creating an invalid cache key, and I have a patch ready
for that on our side that unblocks the upgrade, so I'm not sure how much
we'll end up digging into that mystery!)
--
Ticket URL: <https://code.djangoproject.com/ticket/31654#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.d9b9bdcaf90fd54d34686b9d621a5a7c%40djangoproject.com.