diff --git a/changelog.d/20231208_105820_rra_DM_42093.md b/changelog.d/20231208_105820_rra_DM_42093.md new file mode 100644 index 000000000..4b2612db3 --- /dev/null +++ b/changelog.d/20231208_105820_rra_DM_42093.md @@ -0,0 +1,3 @@ +### Bug fixes + +- Adjust the Redis connection pool parameters to hopefully improve recovery after a Redis server restart. diff --git a/src/gafaelfawr/constants.py b/src/gafaelfawr/constants.py index a6dda6086..d9788eb49 100644 --- a/src/gafaelfawr/constants.py +++ b/src/gafaelfawr/constants.py @@ -128,10 +128,10 @@ REDIS_RETRIES = 10 """How many times to try to connect to Redis before giving up.""" -REDIS_POOL_SIZE = 10 +REDIS_POOL_SIZE = 25 """Size of the Redis connection pool.""" -REDIS_POOL_TIMEOUT = 10 +REDIS_POOL_TIMEOUT = 30 """Seconds to wait for a connection from the pool before giving up.""" REDIS_TIMEOUT = 5 diff --git a/src/gafaelfawr/factory.py b/src/gafaelfawr/factory.py index 2187df799..062de04f4 100644 --- a/src/gafaelfawr/factory.py +++ b/src/gafaelfawr/factory.py @@ -138,22 +138,22 @@ async def from_config(cls, config: Config) -> Self: client.set_credentials("GSSAPI") ldap_pool = AIOConnectionPool(client) - redis_client: Redis = Redis( - connection_pool=BlockingConnectionPool.from_url( - config.redis_url, - password=config.redis_password, - max_connections=REDIS_POOL_SIZE, - retry=Retry( - ExponentialBackoff( - base=REDIS_BACKOFF_START, cap=REDIS_BACKOFF_MAX - ), - REDIS_RETRIES, + redis_pool = BlockingConnectionPool.from_url( + config.redis_url, + password=config.redis_password, + max_connections=REDIS_POOL_SIZE, + retry=Retry( + ExponentialBackoff( + base=REDIS_BACKOFF_START, cap=REDIS_BACKOFF_MAX ), - socket_keepalive=True, - socket_timeout=REDIS_TIMEOUT, - timeout=REDIS_POOL_TIMEOUT, + REDIS_RETRIES, ), + retry_on_timeout=True, + socket_keepalive=True, + socket_timeout=REDIS_TIMEOUT, + timeout=REDIS_POOL_TIMEOUT, ) + redis_client = Redis.from_pool(redis_pool) return cls( config=config, @@ -176,7 +176,6 @@ async def aclose(self) -> None: a different configuration. """ await self.redis.aclose() - await self.redis.connection_pool.disconnect() if self.ldap_pool: await self.ldap_pool.close() await self.uid_cache.clear()