Browse Source

Revert "build: update redis and remove redis-py-cluster (#65282)"

This reverts commit a30c22d903844beeca4ccf06cc44b7a31dad790e.

Co-authored-by: asottile-sentry <103459774+asottile-sentry@users.noreply.github.com>
getsentry-bot 1 year ago
parent
commit
52466b44a9

+ 3 - 0
fixtures/stubs-for-mypy/rediscluster/__init__.pyi

@@ -0,0 +1,3 @@
+from .client import RedisCluster
+
+__all__ = ('RedisCluster',)

+ 8 - 0
fixtures/stubs-for-mypy/rediscluster/client.pyi

@@ -0,0 +1,8 @@
+from typing import TypeVar
+
+from redis import Redis
+
+T = TypeVar("T", str, bytes)
+
+class RedisCluster(Redis[T]):
+    ...

+ 3 - 0
fixtures/stubs-for-mypy/rediscluster/exceptions.pyi

@@ -0,0 +1,3 @@
+from redis.exceptions import RedisError
+
+class ClusterError(RedisError): ...

+ 3 - 2
requirements-base.txt

@@ -52,7 +52,8 @@ fido2>=0.9.2
 python3-saml>=1.15.0
 PyYAML>=6.0.1
 rb>=1.9.0
-redis>=4.1.0
+redis-py-cluster>=2.1.0
+redis>=3.4.1
 requests-oauthlib>=1.2.0
 requests>=2.25.1
 # [start] jsonschema format validators
@@ -62,7 +63,7 @@ rfc3986-validator>=0.1.1
 sentry-arroyo>=2.16.0
 sentry-kafka-schemas>=0.1.50
 sentry-ophio==0.1.5
-sentry-redis-tools>=0.2.0
+sentry-redis-tools>=0.1.7
 sentry-relay>=0.8.45
 sentry-sdk>=1.39.2
 snuba-sdk>=2.0.25

+ 4 - 5
requirements-dev-frozen.txt

@@ -10,7 +10,6 @@ amqp==5.2.0
 anyio==3.7.1
 asgiref==3.7.2
 async-generator==1.10
-async-timeout==4.0.3
 attrs==23.1.0
 avalara==20.9.0
 beautifulsoup4==4.7.1
@@ -159,7 +158,8 @@ pyuwsgi==2.0.23
 pyvat==1.3.15
 pyyaml==6.0.1
 rb==1.10.0
-redis==4.5.4
+redis==3.4.1
+redis-py-cluster==2.1.0
 referencing==0.30.2
 regex==2022.9.13
 reportlab==4.0.7
@@ -179,7 +179,7 @@ sentry-forked-django-stubs==4.2.7.post3
 sentry-forked-djangorestframework-stubs==3.14.5.post1
 sentry-kafka-schemas==0.1.50
 sentry-ophio==0.1.5
-sentry-redis-tools==0.2.0
+sentry-redis-tools==0.1.7
 sentry-relay==0.8.45
 sentry-sdk==1.39.2
 sentry-usage-accountant==0.0.10
@@ -211,11 +211,10 @@ types-pillow==9.5.0.4
 types-protobuf==4.23.0.1
 types-psutil==5.9.5.16
 types-psycopg2==2.9.21
-types-pyopenssl==23.2.0.2
 types-python-dateutil==2.8.19
 types-pytz==2022.1.2
 types-pyyaml==6.0.11
-types-redis==4.6.0.3
+types-redis==3.5.18
 types-requests==2.31.0.20231231
 types-setuptools==65.3.0
 types-simplejson==3.17.7.2

+ 1 - 1
requirements-dev.txt

@@ -53,7 +53,7 @@ types-python-dateutil
 types-pytz
 types-pyyaml
 # make sure to match close-enough to redis==
-types-redis>=4.1
+types-redis<4
 types-requests>=2.31.0.20231231
 types-setuptools
 types-simplejson>=3.17.7.2

+ 3 - 3
requirements-frozen.txt

@@ -9,7 +9,6 @@
 amqp==5.2.0
 anyio==3.7.1
 asgiref==3.7.2
-async-timeout==4.0.3
 attrs==23.1.0
 avalara==20.9.0
 beautifulsoup4==4.7.1
@@ -106,7 +105,8 @@ pyuwsgi==2.0.23
 pyvat==1.3.15
 pyyaml==6.0.1
 rb==1.10.0
-redis==4.5.4
+redis==3.4.1
+redis-py-cluster==2.1.0
 referencing==0.30.2
 regex==2022.9.13
 reportlab==4.0.7
@@ -120,7 +120,7 @@ s3transfer==0.10.0
 sentry-arroyo==2.16.0
 sentry-kafka-schemas==0.1.50
 sentry-ophio==0.1.5
-sentry-redis-tools==0.2.0
+sentry-redis-tools==0.1.7
 sentry-relay==0.8.45
 sentry-sdk==1.39.2
 sentry-usage-accountant==0.0.10

+ 4 - 4
src/sentry/eventstore/processing/multiredis.py

@@ -2,7 +2,7 @@ import hashlib
 from datetime import timedelta
 from typing import TypeVar
 
-from redis.cluster import RedisCluster
+from rediscluster import RedisCluster
 
 from sentry import options
 from sentry.utils.codecs import JSONCodec
@@ -20,10 +20,10 @@ class MultiRedisProcessingStore(EventProcessingStore):
     Adapter to shift traffic from one redis cluster to another
     """
 
-    def __init__(self, old_cluster: str, new_cluster: str):
+    def __init__(self, **options):
         inner = MultiRedisKVStorage(
-            old_cluster=redis_clusters.get(old_cluster),  # type: ignore[arg-type]
-            new_cluster=redis_clusters.get(new_cluster),  # type: ignore[arg-type]
+            old_cluster=redis_clusters.get(options["old_cluster"]),
+            new_cluster=redis_clusters.get(options["new_cluster"]),
         )
         super().__init__(KVStorageCodecWrapper(inner, JSONCodec()))
 

+ 1 - 1
src/sentry/incidents/subscription_processor.py

@@ -10,7 +10,6 @@ from typing import TypeVar, cast
 from django.conf import settings
 from django.db import router, transaction
 from django.utils import timezone
-from sentry_redis_tools.retrying_cluster import RetryingRedisCluster
 from snuba_sdk import Column, Condition, Limit, Op
 
 from sentry import features
@@ -48,6 +47,7 @@ from sentry.snuba.models import QuerySubscription
 from sentry.snuba.tasks import build_query_builder
 from sentry.utils import metrics, redis
 from sentry.utils.dates import to_datetime, to_timestamp
+from sentry.utils.redis import RetryingRedisCluster
 
 logger = logging.getLogger(__name__)
 REDIS_TTL = int(timedelta(days=7).total_seconds())

+ 3 - 4
src/sentry/ingest/transaction_clusterer/rules.py

@@ -60,11 +60,10 @@ class RedisRuleStore:
         key = self._get_rules_key(project)
 
         with client.pipeline() as p:
+            # to be consistent with other stores, clear previous hash entries:
+            p.delete(key)
             if len(rules) > 0:
-                p.hset(key, mapping=rules)
-            else:
-                # to be consistent with other stores, clear previous hash entries:
-                p.delete(key)
+                p.hmset(key, rules)
             p.execute()
 
     def update_rule(self, project: Project, rule: str, last_used: int) -> None:

Some files were not shown because too many files changed in this diff