kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Remove PICKLE_PROTOCOL setting and use Python default

Open rtibbles opened this issue 9 months ago • 5 comments

🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:

  • Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
  • Confirm that you’ve read the guidelines in your comment.

Overview

The PICKLE_PROTOCOL option exists to pin the pickle protocol used by the cache backends. It defaults to 2 (Python 2's max) and is no longer needed — task data is now serialized as JSON, and the cache is the only consumer. If a cache contains data from an incompatible protocol, it should be caught and treated as a cache miss rather than maintained via a global protocol pin.

Complexity: Medium Target branch: release-v0.19.x

Context

The setting is defined in kolibri/utils/options.py under the Python section and consumed in kolibri/deployment/default/cache.py where it's passed to:

  • The disk-based process cache as disk_pickle_protocol
  • The Redis cache as PICKLE_VERSION

The comments in cache.py (lines 33, 48) say "Pin pickle protocol for Python 2 compatibility" which is outdated.

The Change

  1. Remove the PICKLE_PROTOCOL option from the Python section in kolibri/utils/options.py.
  2. Remove the pickle_protocol variable and its usage from kolibri/deployment/default/cache.py — let the cache backends use Python's default protocol.
  3. Add pickle deserialization errors (e.g., pickle.UnpicklingError) to ERRORS_TO_HANDLE in kolibri/deployment/default/custom_django_cache.py, so stale cache entries pickled with an incompatible protocol are silently treated as cache misses.
  4. Remove the outdated "Python 2 compatibility" comments in cache.py.

Acceptance Criteria

  • [ ] The PICKLE_PROTOCOL option is removed from kolibri/utils/options.py
  • [ ] kolibri/deployment/default/cache.py no longer references pickle_protocol or contains Python 2 comments
  • [ ] CustomDjangoCache in kolibri/deployment/default/custom_django_cache.py handles pickle deserialization errors gracefully
  • [ ] All existing tests pass

🤖 This issue was written with AI assistance, under supervision, review and final edits by [@rtibbles] 🤖

rtibbles avatar Feb 16 '26 23:02 rtibbles

I want to work on this.

Swoyamjeetcodes avatar Feb 17 '26 01:02 Swoyamjeetcodes

hello @rtibbles if you are assigning this issue to swoyamjeetcode then pls can you assign Convert facility management issue #14195 to me.

curiouscoder-cmd avatar Feb 17 '26 01:02 curiouscoder-cmd

I have assigned to @Swoyamjeetcodes - as he asked first. @curiouscoder-cmd, there are other available help wanted issues, please look at those. Our guidelines restrict contributors to two issues at once, so it's not either or.

rtibbles avatar Feb 17 '26 01:02 rtibbles

Will raise a PR soon !

Swoyamjeetcodes avatar Feb 17 '26 12:02 Swoyamjeetcodes

@rtibbles check #14198, this commit

Swoyamjeetcodes avatar Feb 17 '26 12:02 Swoyamjeetcodes