Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(seer grouping): Save grouphash metadata before adding seer results #85804

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/sentry/grouping/ingest/seer.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,39 @@ def maybe_check_seer_for_matching_grouphash(
# Update the relevant GroupHash with Seer results
gh_metadata = grouphash_sent.metadata
if gh_metadata:

# TODO: This should never be true (anything created with `objects.create` should have an
# id), but it seems in some cases to happen anyway. This is an attempt to mitigate the
# problem.
metadata_id: Any = (
gh_metadata.id
) # Even mypy knows this should never happen, hence the need for the Any
if metadata_id is None:
logger.info(
"grouphash_metadata.none_id",
extra={
"event_id": event.event_id,
"grouphash": str(event_grouphash),
"grouphash_metadata": str(gh_metadata),
"project": str(event.project),
},
)
gh_metadata.save()

# If that didn't work, log it and bail
metadata_id = gh_metadata.id
if metadata_id is None:
logger.error(
"grouphash_metadata.none_id_fix_failed",
extra={
"event_id": event.event_id,
"grouphash": str(event_grouphash),
"grouphash_metadata": str(gh_metadata),
"project": str(event.project),
},
)
return seer_matched_grouphash

gh_metadata.update(
# Technically the time of the metadata record creation and the time of the Seer
# request will be some milliseconds apart, but a) the difference isn't meaningful
Expand Down
Loading