Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility of unhandled exception during diskcache usage #11767

Closed
rtibbles opened this issue Jan 23, 2024 · 3 comments
Closed

Possibility of unhandled exception during diskcache usage #11767

rtibbles opened this issue Jan 23, 2024 · 3 comments
Assignees
Labels
DEV: backend Python, databases, networking, filesystem... help wanted Open source contributors welcome P2 - normal Priority: Nice to have

Comments

@rtibbles
Copy link
Member

Observed behavior

A very odd behaviour whereby diskcache seems to lose track of its transaction id.

Errors and logs

ERROR 2024-01-23 15:39:39,832 django.request Internal Server Error: /coach/api/notifications/
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/core.py", line 762, in _transact
    yield sql, filenames.append
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/core.py", line 827, in set
    rows = sql(
sqlite3.OperationalError: disk I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/core/handlers/base.py", line 172, in _get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
    sub_match = pattern.resolve(new_path)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
    sub_match = pattern.resolve(new_path)
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 366, in resolve
    sub_match = pattern.resolve(new_path)
  [Previous line repeated 1 more time]
  File "/usr/lib/python3/dist-packages/kolibri/dist/django/urls/resolvers.py", line 361, in resolve
    match = self.regex.search(path)
  File "/usr/lib/python3/dist-packages/kolibri/core/device/translation.py", line 158, in regex
    device_language = get_device_language() or get_settings_language()
  File "/usr/lib/python3/dist-packages/kolibri/core/device/translation.py", line 26, in get_device_language
    if not device_provisioned():
  File "/usr/lib/python3/dist-packages/kolibri/core/device/utils.py", line 68, in device_provisioned
    return get_device_setting("is_provisioned")
  File "/usr/lib/python3/dist-packages/kolibri/core/device/utils.py", line 54, in get_device_setting
    device_settings = DeviceSettings.objects.get()
  File "/usr/lib/python3/dist-packages/kolibri/core/device/models.py", line 73, in get
    cache.set(DEVICE_SETTINGS_CACHE_KEY, model, 600)
  File "/usr/lib/python3/dist-packages/kolibri/deployment/default/custom_django_cache.py", line 76, in set
    return super(CustomDjangoCache, self).set(
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/djangocache.py", line 147, in set
    return self._cache.set(key, value, timeout, read, tag, retry)
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/fanout.py", line 97, in set
    return shard.set(key, value, expire, read, tag, retry)
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/core.py", line 842, in set
    return True
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/lib/python3/dist-packages/kolibri/dist/diskcache/core.py", line 765, in _transact
    assert self._txn_id == tid
AssertionError

Expected behavior

Our CustomDjangoCache object should also handle AssertionErrors:

class CustomDjangoCache(DjangoCache):

Might be simplest to do a small refactor to create a class level handled errors tuple, and then use that in each try/except block to handle.

User-facing consequences

Very limited, has only been observed once in testing.

Context

First reported here: #11765 (comment)

@rtibbles rtibbles added P2 - normal Priority: Nice to have DEV: backend Python, databases, networking, filesystem... help wanted Open source contributors welcome labels Jan 23, 2024
@thesujai
Copy link
Contributor

May i work on this?

@AlexVelezLl
Copy link
Member

Hi @thesujai! Sure! I will assign this to you. Thanks! 👐

@rtibbles
Copy link
Member Author

Fixed in #11808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... help wanted Open source contributors welcome P2 - normal Priority: Nice to have
Projects
None yet
Development

No branches or pull requests

3 participants