Skip to content

Commit

Permalink
fix(similarity): Catch InvalidEnhancerConfig in backfill (#77861)
Browse files Browse the repository at this point in the history
Catch InvalidEnhancerConfig in similarity backfill and skip that group
  • Loading branch information
jangjodi authored Sep 20, 2024
1 parent 2712631 commit 304b5f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sentry import options
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.grouping.api import GroupingConfigNotFound
from sentry.grouping.enhancer.exceptions import InvalidEnhancerConfig
from sentry.models.project import Project
from sentry.seer.similarity.utils import killswitch_enabled, project_is_seer_eligible
from sentry.silo.base import SiloMode
Expand All @@ -31,6 +32,7 @@
BACKFILL_NAME = "backfill_grouping_records"
BULK_DELETE_METADATA_CHUNK_SIZE = 100
SEER_ACCEPTABLE_FAILURE_REASONS = ["Gateway Timeout", "Service Unavailable"]
EVENT_INFO_EXCEPTIONS = (GroupingConfigNotFound, ResourceDoesNotExist, InvalidEnhancerConfig)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -219,7 +221,7 @@ def backfill_seer_grouping_records_for_project(
nodestore_results, group_hashes_dict = get_events_from_nodestore(
project, filtered_snuba_results, groups_to_backfill_with_no_embedding_has_snuba_row
)
except (GroupingConfigNotFound, ResourceDoesNotExist):
except EVENT_INFO_EXCEPTIONS:
metrics.incr("sentry.tasks.backfill_seer_grouping_records.grouping_config_error")
nodestore_results, group_hashes_dict = GroupStacktraceData(data=[], stacktrace_list=[]), {}

Expand Down
35 changes: 20 additions & 15 deletions tests/sentry/tasks/test_backfill_seer_grouping_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from sentry.api.exceptions import ResourceDoesNotExist
from sentry.conf.server import SEER_SIMILARITY_MODEL_VERSION
from sentry.eventstore.models import Event
from sentry.grouping.api import GroupingConfigNotFound
from sentry.grouping.enhancer.exceptions import InvalidEnhancerConfig
from sentry.issues.occurrence_consumer import EventLookupError
from sentry.models.group import Group, GroupStatus
from sentry.models.grouphash import GroupHash
Expand Down Expand Up @@ -1500,23 +1502,26 @@ def test_backfill_seer_grouping_records_nodestore_grouping_config_not_found(
mock_lookup_group_data_stacktrace_bulk,
mock_logger,
):
mock_lookup_group_data_stacktrace_bulk.side_effect = ResourceDoesNotExist()
exceptions = (GroupingConfigNotFound(), ResourceDoesNotExist(), InvalidEnhancerConfig())

with TaskRunner():
backfill_seer_grouping_records_for_project(self.project.id, None)
for exception in exceptions:
mock_lookup_group_data_stacktrace_bulk.side_effect = exception

groups = Group.objects.all()
group_ids_sorted = sorted([group.id for group in groups], reverse=True)
mock_call_next_backfill.assert_called_with(
last_processed_group_id=group_ids_sorted[-1],
project_id=self.project.id,
last_processed_project_index=0,
cohort=None,
enable_ingestion=False,
skip_processed_projects=False,
skip_project_ids=None,
worker_number=None,
)
with TaskRunner():
backfill_seer_grouping_records_for_project(self.project.id, None)

groups = Group.objects.all()
group_ids_sorted = sorted([group.id for group in groups], reverse=True)
mock_call_next_backfill.assert_called_with(
last_processed_group_id=group_ids_sorted[-1],
project_id=self.project.id,
last_processed_project_index=0,
cohort=None,
enable_ingestion=False,
skip_processed_projects=False,
skip_project_ids=None,
worker_number=None,
)

@with_feature("projects:similarity-embeddings-backfill")
@patch("sentry.tasks.embeddings_grouping.utils.logger")
Expand Down

0 comments on commit 304b5f3

Please sign in to comment.