-
Notifications
You must be signed in to change notification settings - Fork 28
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: Remove slow update repos query from trigger function #207
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know!. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #207 +/- ##
=======================================
Coverage 95.60% 95.60%
=======================================
Files 600 601 +1
Lines 15233 15240 +7
=======================================
+ Hits 14563 14570 +7
Misses 670 670
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report
@@ Coverage Diff @@
## main #207 +/- ##
=======================================
Coverage 95.60% 95.60%
=======================================
Files 600 601 +1
Lines 15233 15240 +7
=======================================
+ Hits 14563 14570 +7
Misses 670 670
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov Report
@@ Coverage Diff @@
## main #207 +/- ##
=======================================
+ Coverage 95.50 95.52 +0.02
=======================================
Files 714 715 +1
Lines 15639 15635 -4
=======================================
- Hits 14936 14935 -1
+ Misses 703 700 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Purpose/Motivation
This query is often very slow. I don't know why exactly b/c the condition is only on the primary key. I suspect there's just so much contention for that repo row that we're waiting on locks most of the time. This seems to mostly be the case for repos that receive a lot of continuous uploads.
We recently removed this query from the upload endpoint in #200 and moved it into the worker in codecov/worker#150
Unfortunately it's still running as part of the
insert commit
query though due to a trigger:codecov-api/legacy_migrations/migrations/legacy_sql/main/triggers/commits.py
Line 104 in 019d273
An
explain (analyze, buffers
of aninsert commit
query for a large repo shows that a good deal of time is spent inside that trigger function:I separately
explain analyzed
theupdate repos
query for the same repo and it took a very long time.Links to relevant tickets
N/A
What does this PR do?
Creates a migration to replace the function and omit the
update repos
query. I don't think it's necessary to do this in the trigger. The value may become slightly out-of-date but the worker will update the value as soon as we start processing the commit.Marked the migration as risky since we'll plan to run it after hours.