-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(db): Refactor GroupeRelease to reduce rollbacks #88885
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
ref(db): Refactor GroupeRelease to reduce rollbacks #88885
Conversation
| if instance is None: | ||
| try: | ||
| with transaction.atomic(router.db_for_write(cls)): | ||
| if random.random() < options.get("grouprelease.new_get_or_create.rollout"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to change this pull request, but for the others you could use sentry.options.rollout.in_random_rollout to encapsulate the random + option read together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't aware that that exists, thanks!
I will update the docs to point to sentry.options.rollout.in_random_rollout instead of proposing to use random.random()
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #88885 +/- ##
=======================================
Coverage 87.73% 87.73%
=======================================
Files 10072 10072
Lines 569614 569711 +97
Branches 22373 22373
=======================================
+ Hits 499734 499824 +90
- Misses 69481 69488 +7
Partials 399 399 |
Refactor of `get_or_create` method of `GroupRelease` model, preparing it for gradual rollout and to decrease the number of rollbacks it does since almost every attempt of insertions for this model results in a rollback. ## Why are we doing this Currently we are doing around 300 rollbacks per second, mostly caused by overly optimistic writes - almost all of the writes result in the rollback because the data already exists in the table, and for those occasions `get_or_create` is more suitable since SELECT statement is more performant than ROLLBACK when they happen most of the times. [Datadog notebok with investagtion](https://app.datadoghq.com/notebook/12067672/postgres-rollback-investigation?range=604800000&start=1743184480708&live=true), where 3 problematic models where detected: - `GroupRelease` - `Commit` - `EnvironmentProject` Models will be refactored one at the time, and the refactor will be rolled out gradually: 10% - 50% - 100%
In #88885 rollout option was introduced. Now it is rolled out to 100%, and it's time to do the clean up. In the next PRs options automator flag and option registration will be removed, once this is merged and fully deployed
In #88885 rollout option was introduced. Now it is rolled out to 100%, and it's time to do the clean up. In the next PRs options automator flag and option registration will be removed, once this is merged and fully deployed
Similar to how it was done in: #88885 Refactor of `add_project` method of `Environment` model, preparing it for gradual rollout and to decrease the number of rollbacks it does since almost every attempt of insertions for this model results in a rollback. In this method `EnvironmentProject` was doing overly optimistic inserts leading to us having almost 100 rollbacks/second coming just from this model ## Why are we doing this Currently we are doing around 300 rollbacks per second, mostly caused by overly optimistic writes - almost all of the writes result in the rollback because the data already exists in the table, and for those occasions `get_or_create` is more suitable since SELECT statement is more performant than ROLLBACK when they happen most of the times. [Datadog notebok with investagtion](https://app.datadoghq.com/notebook/12067672/postgres-rollback-investigation?range=604800000&start=1743184480708&live=true), where 3 problematic models where detected: - ~GroupRelease~ - `Commit` - `EnvironmentProject` Models will be refactored one at the time, and the refactor will be rolled out gradually: 10% - 50% - 100%
In #88885 rollout option was introduced. Now it is rolled out to 100%, and it's time to do the clean up. In the next PRs options automator flag and option registration will be removed, once this is merged and fully deployed
Similar to how it was done in: #88885 Refactor of `add_project` method of `Environment` model, preparing it for gradual rollout and to decrease the number of rollbacks it does since almost every attempt of insertions for this model results in a rollback. In this method `EnvironmentProject` was doing overly optimistic inserts leading to us having almost 100 rollbacks/second coming just from this model ## Why are we doing this Currently we are doing around 300 rollbacks per second, mostly caused by overly optimistic writes - almost all of the writes result in the rollback because the data already exists in the table, and for those occasions `get_or_create` is more suitable since SELECT statement is more performant than ROLLBACK when they happen most of the times. [Datadog notebok with investagtion](https://app.datadoghq.com/notebook/12067672/postgres-rollback-investigation?range=604800000&start=1743184480708&live=true), where 3 problematic models where detected: - ~GroupRelease~ - `Commit` - `EnvironmentProject` Models will be refactored one at the time, and the refactor will be rolled out gradually: 10% - 50% - 100%
Refactor of
get_or_createmethod ofGroupReleasemodel, preparing it for gradual rollout and to decrease the number of rollbacks it does since almost every attempt of insertions for this model results in a rollback.Why are we doing this
Currently we are doing around 300 rollbacks per second, mostly caused by overly optimistic writes - almost all of the writes result in the rollback because the data already exists in the table, and for those occasions
get_or_createis more suitable since SELECT statement is more performant than ROLLBACK when they happen most of the times.Datadog notebok with investagtion, where 3 problematic models where detected:
GroupReleaseCommitEnvironmentProjectModels will be refactored one at the time, and the refactor will be rolled out gradually: 10% - 50% - 100%