From db89874bb07997df795818de5e24ff7b496c0606 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 9 Sep 2025 20:24:04 +0000 Subject: [PATCH] cache: Write cache_key_prefixes without any compression. This ensures that the new choice of zstd compression does not break the previous, still-running, install during upgrades when the list of cache_key_prefixes is updated. --- zerver/lib/cache.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 03b12223e1..a071f44fe1 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -69,7 +69,17 @@ def update_cached_cache_key_prefixes() -> list[str]: continue with open(filename) as f: found_prefixes.add(f.readline().removesuffix("\n")) - caches["default"].set("cache_key_prefixes", list(found_prefixes), timeout=60 * 60 * 24) # 24h + + # We reach into the bmemcached client directly to do this set + # *without* compression, so that changes in our choice of + # bmemcached compression algorithm are always + # backwards-compatible. + caches["default"]._cache.set( # type: ignore[attr-defined] # not in stubs + caches["default"].make_key("cache_key_prefixes"), + list(found_prefixes), + 60 * 60 * 24, # 24h + compress_level=0, + ) return list(found_prefixes)