Skip to content

Commit 3486624

Browse files
Revert "perf: move assemble status to redis (#70376)"
This reverts commit 7efeed8. Co-authored-by: anonrig <1935246+anonrig@users.noreply.github.com>
1 parent 9fb864e commit 3486624

File tree

5 files changed

+4
-66
lines changed

5 files changed

+4
-66
lines changed

src/sentry/conf/server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def env(
135135
SENTRY_METRIC_META_REDIS_CLUSTER = "default"
136136
SENTRY_ESCALATION_THRESHOLDS_REDIS_CLUSTER = "default"
137137
SENTRY_SPAN_BUFFER_CLUSTER = "default"
138-
SENTRY_ASSEMBLE_CLUSTER = "default"
139138

140139
# Hosts that are allowed to use system token authentication.
141140
# http://en.wikipedia.org/wiki/Reserved_IP_addresses

src/sentry/options/defaults.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,10 +2298,6 @@
22982298
flags=FLAG_BOOL | FLAG_AUTOMATOR_MODIFIABLE,
22992299
)
23002300

2301-
2302-
# Switch to read assemble status from Redis instead of memcache
2303-
register("assemble.read_from_redis", default=False, flags=FLAG_AUTOMATOR_MODIFIABLE)
2304-
23052301
# Sampling rates for testing Rust-based grouping enhancers
23062302

23072303
# Rate at which to run the Rust implementation of `assemble_stacktrace_component`

src/sentry/tasks/assemble.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
from abc import ABC, abstractmethod
77
from datetime import datetime
88
from os import path
9-
from typing import IO, TYPE_CHECKING, Generic, NamedTuple, Protocol, TypeVar
9+
from typing import IO, Generic, NamedTuple, Protocol, TypeVar
1010

11-
import orjson
1211
import sentry_sdk
13-
from django.conf import settings
1412
from django.db import IntegrityError, router
1513
from django.db.models import Q
1614
from django.utils import timezone
@@ -41,16 +39,13 @@
4139
from sentry.models.releasefile import ReleaseArchive, ReleaseFile, update_artifact_index
4240
from sentry.silo.base import SiloMode
4341
from sentry.tasks.base import instrumented_task
44-
from sentry.utils import metrics, redis
42+
from sentry.utils import metrics
4543
from sentry.utils.db import atomic_transaction
4644
from sentry.utils.files import get_max_file_size
4745
from sentry.utils.sdk import bind_organization_context, configure_scope
4846

4947
logger = logging.getLogger(__name__)
5048

51-
if TYPE_CHECKING:
52-
from rediscluster import RedisCluster
53-
5449

5550
class ChunkFileState:
5651
OK = "ok" # File in database
@@ -169,18 +164,12 @@ def _get_cache_key(task, scope, checksum):
169164
% (
170165
str(scope).encode("ascii"),
171166
checksum.encode("ascii"),
172-
str(task).encode(),
167+
str(task).encode("utf-8"),
173168
)
174169
).hexdigest()
175170
)
176171

177172

178-
def _get_redis_cluster_for_assemble() -> RedisCluster:
179-
cluster_key = settings.SENTRY_ASSEMBLE_CLUSTER
180-
return redis.redis_clusters.get(cluster_key) # type: ignore[return-value]
181-
182-
183-
@sentry_sdk.tracing.trace
184173
def get_assemble_status(task, scope, checksum):
185174
"""
186175
Checks the current status of an assembling task.
@@ -190,43 +179,26 @@ def get_assemble_status(task, scope, checksum):
190179
notice or error message.
191180
"""
192181
cache_key = _get_cache_key(task, scope, checksum)
193-
194-
if options.get("assemble.read_from_redis"):
195-
client = _get_redis_cluster_for_assemble()
196-
rv = client.get(cache_key)
197-
198-
# It is stored as bytes with [state, detail] on Redis.
199-
if rv:
200-
[state, detail] = orjson.loads(rv)
201-
rv = (state, detail)
202-
else:
203-
rv = default_cache.get(cache_key)
204-
182+
rv = default_cache.get(cache_key)
205183
if rv is None:
206184
return None, None
207185
return tuple(rv)
208186

209187

210-
@sentry_sdk.tracing.trace
211188
def set_assemble_status(task, scope, checksum, state, detail=None):
212189
"""
213190
Updates the status of an assembling task. It is cached for 10 minutes.
214191
"""
215192
cache_key = _get_cache_key(task, scope, checksum)
216193
default_cache.set(cache_key, (state, detail), 600)
217-
redis_client = _get_redis_cluster_for_assemble()
218-
redis_client.set(name=cache_key, value=orjson.dumps([state, detail]), ex=600)
219194

220195

221-
@sentry_sdk.tracing.trace
222196
def delete_assemble_status(task, scope, checksum):
223197
"""
224198
Deletes the status of an assembling task.
225199
"""
226200
cache_key = _get_cache_key(task, scope, checksum)
227201
default_cache.delete(cache_key)
228-
redis_client = _get_redis_cluster_for_assemble()
229-
redis_client.delete(cache_key)
230202

231203

232204
@instrumented_task(

src/sentry/testutils/helpers/redis.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def use_redis_cluster(
1212
cluster_id: str = "cluster",
1313
high_watermark: int = 100,
1414
with_settings: dict[str, Any] | None = None,
15-
with_options: dict[str, Any] | None = None,
1615
) -> Generator[None, None, None]:
1716
# Cluster id needs to be different than "default" to distinguish redis instance with redis cluster.
1817

@@ -33,9 +32,6 @@ def use_redis_cluster(
3332
},
3433
}
3534

36-
if with_options:
37-
options.update(with_options)
38-
3935
settings = dict(with_settings or {})
4036
settings["SENTRY_PROCESSING_SERVICES"] = {"redis": {"redis": cluster_id}}
4137

tests/sentry/tasks/test_assemble.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import io
22
import os
3-
import uuid
43
from datetime import UTC, datetime, timedelta
54
from hashlib import sha1
65
from unittest import mock
@@ -29,13 +28,10 @@
2928
assemble_artifacts,
3029
assemble_dif,
3130
assemble_file,
32-
delete_assemble_status,
3331
get_assemble_status,
34-
set_assemble_status,
3532
)
3633
from sentry.testutils.cases import TestCase
3734
from sentry.testutils.helpers.datetime import freeze_time
38-
from sentry.testutils.helpers.redis import use_redis_cluster
3935

4036

4137
class BaseAssembleTest(TestCase):
@@ -1051,24 +1047,3 @@ def test_index_if_needed_with_newer_bundle_already_stored(
10511047
organization_id=self.organization.id,
10521048
artifact_bundles=[(artifact_bundle_1, mock.ANY)],
10531049
)
1054-
1055-
1056-
@use_redis_cluster(with_options={"assemble.read_from_redis": True})
1057-
def test_redis_assemble_status():
1058-
task = AssembleTask.DIF
1059-
project_id = uuid.uuid4().hex
1060-
checksum = uuid.uuid4().hex
1061-
1062-
# If it doesn't exist, it should return correct values.
1063-
assert get_assemble_status(task=task, scope=project_id, checksum=checksum) == (None, None)
1064-
1065-
# Test setter
1066-
set_assemble_status(task, project_id, checksum, ChunkFileState.CREATED, detail="cylons")
1067-
assert get_assemble_status(task=task, scope=project_id, checksum=checksum) == (
1068-
"created",
1069-
"cylons",
1070-
)
1071-
1072-
# Deleting should actually delete it.
1073-
delete_assemble_status(task, project_id, checksum=checksum)
1074-
assert get_assemble_status(task=task, scope=project_id, checksum=checksum) == (None, None)

0 commit comments

Comments
 (0)