-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: improve the performance of list artifacts #18610
Conversation
Codecov Report
@@ Coverage Diff @@
## main #18610 +/- ##
==========================================
- Coverage 67.40% 67.38% -0.02%
==========================================
Files 984 984
Lines 107010 107029 +19
Branches 2670 2670
==========================================
- Hits 72127 72121 -6
- Misses 31001 31025 +24
- Partials 3882 3883 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
14bb443
to
f12c209
Compare
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.
please move the raw sql to the dao layer as we discussed.
f12c209
to
b29cf93
Compare
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.
lgtm
1. Change the query for listing tasks of scan which can use the db index. 2. Add the gin index for task.extra_attrs.report_uuids Fixes: goharbor#18013 Signed-off-by: chlins <[email protected]>
b29cf93
to
7884e3c
Compare
@chlins It it possible to backport this to v2.7? |
@dioguerra Yes, it will be backported to the patch version of v2.7 and v2.8. |
Hey @chlins, is there anything I can do to help get this fix into 2.7 & 2.8? I'm happy to try and prepare the PRs for this? |
@dkulchinsky Thanks, it has been back ported to v2.7.3 and v2.8.1, you can try to upgrade to these versions. |
Ohh! that's great @chlins 👍🏼 looks like v2.7.3 was not released yet though, but I see the cherry-pick was merged #18632 Will wait for v2.7.3, hopefully soon 😄🤞🏼 |
1. Change the query for listing tasks of scan which can use the db index. 2. Add the gin index for task.extra_attrs.report_uuids Fixes: goharbor#18013 Signed-off-by: chlins <[email protected]> Signed-off-by: Wilfred Almeida <[email protected]>
Fixes: #18013
Thank you for contributing to Harbor!
Comprehensive Summary of your change
Situation
The issue is that when the db has the large number of tasks(scan or other), the API of list artifacts will be quite slow when set the query parameter
with_scan_overview=true
, and also cost many db CPU resource. The root cause for the problem is that when querying scan reports, it is necessary to look up the scan tasks to obtain their status. However, the previous lookup method resulted in a full table scan of the database, which caused slow response times and increased resource utilization in cases with large amounts of data.Improve
The data size of testing environment.
Artifacts: 100000+
Tasks: 500000+
Testing API:
https://harbor.domain/api/v2.0/projects/project-001/repositories/repository-100/artifacts?with_tag=false&with_scan_overview=true&with_label=false&with_accessory=false&page_size=50&page=1
Issue being fixed
Fixes
Please indicate you've done the following: