Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grouping): Fix missing
date_added
in grouphash metadata (#86078)
Normally, when storing Seer results in grouphash metadata, we use the metadata's `date_added` value as the value for `seer_date_sent`. Because of race conditions, though, it's possible for `date_added` to be `None` (see below). Rather than use `None` for both, this fixes it so that the equivalence can go in reverse, in other words, so that we use the `seer_date_sent` timestamp for `date_aded`. (The difference between the two should be a matter of milliseconds, so there's no loss of accuracy.) (The race condition goes like this: Events A and B, which have the same new hash, hit our servers nearly simultaneously. A gets to `get_or_create_grouphashes` first, so from the `GroupHash.objects.get_or_create` call, it gets `created = True`, while B gets `created = False`. Now they're both passed to `create_or_update_grouphash_metadata_if_needed`, and both hit a call to `GroupHashMetadata.objects.get_or_create`. This time, however, it's B which wins the race, and gets `created = True`. It's therefore the one which makes it past the `if not created` check, but because it lost the first race, we mistake it for an existing grouphash and null out `date_added`. (The code for this is here[1] and here[2].)) [1] https://github.com/getsentry/sentry/blob/0339d3a90475b8682362b9fc3830b19b0d759070/src/sentry/grouping/ingest/hashing.py#L229-L237 [2] https://github.com/getsentry/sentry/blob/ea02541f2a5562c51acba855655dcdb6005f7fe9/src/sentry/grouping/ingest/grouphash_metadata.py#L140-L163
- Loading branch information