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

fix: infinite cache growth #1001

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/20240208_111236_regis_infinite_course_cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- 💥[Bugfix] Prevent infinite growth of course structure cache in Redis. (by @regisb)
- Redis is now configured with a maximum memory size of 4GB. If this is too low for your platform, you should increase this value using the new "redis-conf" patch.
- Make sure that course structure cache keys have an actual timeout.
- [Feature] Introduce the "redis-conf" patch. (by @regisb)
7 changes: 7 additions & 0 deletions docs/reference/patches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ File: ``apps/openedx/settings/lms/production.py``

Python-formatted LMS settings in production. Values defined here override the values from :patch:`openedx-lms-common-settings`.

``redis-conf``
==============

File: ``apps/redis/redis.conf``

Implement this patch to override hard-coded Redis configuration values. See the `Redis configuration reference <https://redis.io/docs/management/config-file/>`__`.

``uwsgi-config``
================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"course_structure_cache": {
"KEY_PREFIX": "course_structure",
"TIMEOUT": 7200,
"TIMEOUT": 604800, # 1 week
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://{% if REDIS_USERNAME and REDIS_PASSWORD %}{{ REDIS_USERNAME }}:{{ REDIS_PASSWORD }}{% endif %}@{{ REDIS_HOST }}:{{ REDIS_PORT }}/{{ OPENEDX_CACHE_REDIS_DB }}",
},
Expand Down
7 changes: 7 additions & 0 deletions tutor/templates/apps/redis/redis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes

############################## MEMORY MANAGEMENT ################################

maxmemory 4gb
maxmemory-policy allkeys-lru

{{ patch("redis-conf") }}
3 changes: 3 additions & 0 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ RUN git config --global user.email "tutor@overhang.io" \
{{ patch("openedx-dockerfile-git-patches-default") }}
{%- else %}
# Patch edx-platform
# Prevent course structure cache infinite growth
# https://github.com/openedx/edx-platform/pull/34210
RUN curl -fsSL https://github.com/openedx/edx-platform/commit/ad201cd664b6c722cbefcbda23ae390c06daf621.patch | git am
{%- endif %}

{# Example: RUN curl -fsSL https://github.com/openedx/edx-platform/commit/<GITSHA1>.patch | git am #}
Expand Down
Loading