Add Uniqueness Validation & Change SentryIssueFinder to be Deterministic
What does this MR do?
This MR solves 2 problems:
-
We realized that we cannot validate against
sentry_issue_identifer
and removed that validation because users may hook up multiple instances and it is an incrementing id but we still only want users to create one gitlab_issue from a single sentry issue. -
Since it is possible to have duplicate
sentry_issue_identifer
's per project (based on the validation being removed and no db constraint) we want to make sure theSentryIssueFinder
is deterministic and selects the most recent associated issue.
Resolves #196808 (closed)
Technical Implementation
This adds a custom application level validation of sentry_issue_identifer
scoped to the project_id
and then makes sure that in all places where we find a sentry issue we use the most recent record that can be found based on sentry_issue_identifer
and project_id
(this is because it is possible that we have 2 records for a given sentry_issue_identifer and project_id already).
As background, we originally considered adding project_id
to the sentry_issues
table so that the SentryIssueFinder could avoid a join on issues(a larger table than projects) and to enable the use of scope
in the validation. We decided not to provide the potentially pre-mature optimization of adding project_id.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content