Skip to content
2 changes: 1 addition & 1 deletion snuba/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class RedisClientKey(Enum):
socket_timeout=1,
),
RedisClientKey.RATE_LIMITER: _initialize_specialized_redis_cluster(
settings.REDIS_CLUSTERS["rate_limiter"], socket_timeout=0.5
settings.REDIS_CLUSTERS["rate_limiter"], socket_timeout=0.1
),
RedisClientKey.SUBSCRIPTION_STORE: _initialize_specialized_redis_cluster(
settings.REDIS_CLUSTERS["subscription_store"],
Expand Down
6 changes: 6 additions & 0 deletions snuba/state/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from typing import Any, Iterator, MutableMapping, Optional, Sequence, Type
from typing import ChainMap as TypingChainMap

from redis.exceptions import TimeoutError as RedisTimeoutError

from snuba import environment, state
from snuba.redis import RedisClientKey, get_redis_client
from snuba.state import get_configs, set_config
Expand Down Expand Up @@ -279,6 +281,8 @@ def rate_limit_start_request(
# if something goes wrong, we don't want to block the request,
# set the values such that they pass under any limit
logger.exception(ex)
if isinstance(ex, RedisTimeoutError):
metrics.increment("ratelimiter_redis_timeout", tags={"function": "start_request"})
return RateLimitStats(rate=-1, concurrent=-1)

per_second = historical / float(state.rate_lookback_s)
Expand Down Expand Up @@ -313,6 +317,8 @@ def rate_limit_finish_request(
pipe.execute()
except Exception as ex:
logger.exception(ex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't want to log this exeption. it just becomes a sentry error and we want to avoid that.

if isinstance(ex, RedisTimeoutError):
metrics.increment("ratelimiter_redis_timeout", tags={"function": "finish_request"})


@contextmanager
Expand Down
Loading