Skip to content

Commit

Permalink
cache: handle uncaught redis exception (PROJQUAY-2614) (#907)
Browse files Browse the repository at this point in the history
- Handles uncaught client exceptions so that Quay is able to fallback to
querying the database.
- Also updates the redis library version to address
Grokzen/redis-py-cluster#370
  • Loading branch information
kleesc committed Oct 13, 2021
1 parent a29f3e0 commit ccf6ada
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
22 changes: 19 additions & 3 deletions data/cache/impl.py
Expand Up @@ -263,7 +263,13 @@ def retrieve(self, cache_key, loader, should_cache=is_not_none):
else:
cache_count.labels("miss").inc()
except RedisError as re:
logger.warning("Got exception when trying to retrieve key %s", cache_key.key)
logger.warning(
"Got RedisError exception when trying to retrieve key %s: %s", cache_key.key, re
)
except Exception as e:
logger.exception(
"Got unknown exception when trying to retrieve key %s: %s", cache_key.key, e
)

logger.debug("Found no result in cache for key %s; calling loader", cache_key.key)
result = loader()
Expand Down Expand Up @@ -291,9 +297,19 @@ def retrieve(self, cache_key, loader, should_cache=is_not_none):
result,
cache_key.expiration,
)
except:
except RedisError as re:
logger.warning(
"Got exception when trying to set key %s to %s", cache_key.key, result
"Got RedisError exception when trying to set key %s to %s: %s",
cache_key.key,
result,
re,
)
except Exception as e:
logger.exception(
"Got unknown exception when trying to set key %s to %s: %s",
cache_key.key,
result,
e,
)
else:
logger.debug("Not caching loaded result for key %s: %s", cache_key.key, result)
Expand Down
4 changes: 2 additions & 2 deletions requirements-osbs.txt
Expand Up @@ -39,7 +39,7 @@ docutils==0.15.2
dumb-init==1.2.2
elasticsearch==7.0.4
elasticsearch-dsl==7.0.0
fakeredis==1.1.0
fakeredis==1.6.1
Flask==1.1.1
Flask-Cors==3.0.9
Flask-Login==0.4.1
Expand Down Expand Up @@ -138,7 +138,7 @@ pytz==2019.3
PyYAML==5.4
raven==6.10.0
recaptcha2==0.1
redis==3.3.11
redis==3.5.3
redis-py-cluster==2.1.3
redlock==1.2.0
rehash==1.0.0
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Expand Up @@ -40,7 +40,7 @@ docutils==0.15.2
dumb-init==1.2.2
elasticsearch==7.0.4
elasticsearch-dsl==7.0.0
fakeredis==1.1.0
fakeredis==1.6.1
Flask==1.1.1
Flask-Cors==3.0.9
Flask-Login==0.4.1
Expand Down Expand Up @@ -129,7 +129,7 @@ pytz==2019.3
PyYAML==5.4
raven==6.10.0
recaptcha2==0.1
redis==3.3.11
redis==3.5.3
redis-py-cluster==2.1.3
redlock==1.2.0
rehash==1.0.0
Expand Down

0 comments on commit ccf6ada

Please sign in to comment.