From b71dc0fe7d8250d376e52cac6a35856f71dfe30a Mon Sep 17 00:00:00 2001 From: Nick Mills-Barrett Date: Wed, 11 Oct 2023 14:25:07 +0100 Subject: [PATCH] Handle jump not being installed in code --- .github/workflows/beeper-ci.yml | 1 - synapse/replication/tcp/external_sharded_cache.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/beeper-ci.yml b/.github/workflows/beeper-ci.yml index 0888bfbcbd5f..7f77290ffdf0 100644 --- a/.github/workflows/beeper-ci.yml +++ b/.github/workflows/beeper-ci.yml @@ -35,7 +35,6 @@ jobs: - uses: actions/setup-python@v2 - run: pip install poetry - run: poetry install --extras all - - run: poetry run pip install jump-consistent-hash - run: poetry run trial -j4 tests test-sytest: diff --git a/synapse/replication/tcp/external_sharded_cache.py b/synapse/replication/tcp/external_sharded_cache.py index 2c8078a964b4..c6ec24b05fc1 100644 --- a/synapse/replication/tcp/external_sharded_cache.py +++ b/synapse/replication/tcp/external_sharded_cache.py @@ -18,7 +18,6 @@ from collections import defaultdict from typing import TYPE_CHECKING, Any, Callable, Coroutine, Dict, List, Optional, Union -import jump from prometheus_client import Counter, Histogram from txredisapi import ConnectionError, ConnectionHandler, RedisError @@ -32,6 +31,13 @@ if TYPE_CHECKING: from synapse.server import HomeServer +try: + import jump +except ImportError: + has_jump = False +else: + has_jump = True + set_counter = Counter( "synapse_external_sharded_cache_set", "Number of times we set a cache", @@ -82,6 +88,10 @@ def __init__(self, hs: "HomeServer"): self._reactor = hs.get_reactor() if hs.config.redis.redis_enabled and hs.config.redis.cache_shard_hosts: + if not has_jump: + logger.error("Cannot start sharded cache, jump module not found!") + return + for shard in hs.config.redis.cache_shard_hosts: logger.info( "Connecting to redis (host=%r port=%r) for external cache",