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

temp: Add temporary monitoring for large memcache keys #36034

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
10 changes: 10 additions & 0 deletions common/djangoapps/util/memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from django.conf import settings
from django.utils.encoding import smart_str
from edx_django_utils.monitoring.utils import increment


def fasthash(string):
Expand Down Expand Up @@ -48,9 +49,18 @@ def safe_key(key, key_prefix, version):
# Attempt to combine the prefix, version, and key
combined = ":".join([key_prefix, version, key])

# Temporary: Add observability to large-key hashing to help us
# understand the safety of a cutover from md4 to blake2b hashing.
# See https://github.com/edx/edx-arch-experiments/issues/872
increment('memcache.safe_key.called')

# If the total length is too long for memcache, hash it
if len(combined) > 250:
combined = fasthash(combined)
# Temporary: See
# https://github.com/edx/edx-arch-experiments/issues/872 and
# previous comment.
increment('memcache.safe_key.hash_large')

# Return the result
return combined
Loading