Repository navigation
Speed up and fix the build search filters - #1281
Merged
Merged
Conversation
The rpm_* filters paged through the Pulp API (100 packages per request) to collect the hrefs of the matching packages, which took up to 73 s for rpm_name=kernel on production, and then matched them against build_artifacts.href, which had no index. Read the hrefs from the Pulp database with the same exact-match filters instead, and add an index on build_artifacts.href, created concurrently so that the migration doesn't lock artifact uploads. The project filter searched "/<project>" anywhere in the task URL, so "rpm" or "git" matched every build through ".../rpms/..." or "//git.almalinux.org". Match the beginning of the repository or SRPM name, i.e. the last part of the URL, only.
It isn't known yet how much of the rpm_* filter time is left in the database once the hrefs come from the Pulp database instead of the Pulp API, so add the index later if the measurements show it is needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
rpm_*filters are slow. Measured on production (page 1):rpm_name=bashrpm_name=kernel_get_pulp_hrefs()collects the hrefs of matching packages through the Pulp REST API, whichPulpClientpages through 100 packages per request, and thenBuildTaskArtifact.href IN (...)runs in the correlated EXISTS of both the page and the count query, whilebuild_artifacts.hrefhas no index.projectfilter matches unrelated builds. It isBuildTaskRef.url LIKE '%/<project>%', and every URL looks likehttps://git.almalinux.org/rpms/<name>.git, soproject=rpmorproject=rpmsreturns every build, and so doesproject=git(//git.almalinux.org).Changes
rpm_*filters read the hrefs from the Pulp database (pulp_asyncsession, already used by/package_info/) with the same semantics as the API filters: exact matches, empty values don't filter. This resolves the existing# TODO: we can get packages from pulp database.projectmatches the beginning of the repository or SRPM file name only, i.e. the last part of the URL (url ~ '/<escaped project>[^/]*$').chstill findschan,kernelfindskernelandkernel-rt;rpmfinds only repositories whose name starts withrpm.Tests
tests/test_utils/test_pulp_package_hrefs.pyruns the Pulp lookup against a realrpm_packagetable (created in the test database only with the columns the lookup uses): exact names (bashdoesn't findbash-doc), combinations of fields, empty values, no matches.test_get_builds_filtersgotproject=ch/rpm/rpms/git/almalinux/hancases;rpm,rpmsandgitfail on the current code.rpm_*API tests mock the new lookup instead ofPulpClient.get_rpm_packages.tests/test_ovalexcluded: it can't be imported in the local image,No module named 'almalinux', unrelated).Not measured against the real Pulp database: there's no access to it from outside, so the new
rpm_*timing will show on deployment. Thehref IN (...)part still runs without an index onbuild_artifacts.href; it wasn't measured separately from the API paging, so an index can be added later if the timing after deployment shows it is needed. A filter byrpm_archalone still matches millions of packages and stays slow (it was slower with the API paging).🤖 Generated with Claude Code