Skip to content

Speed up and fix the build search filters - #1281

Merged
anfimovdm merged 2 commits into
AlmaLinux:masterfrom
eabdullin1:build-search-filters
Nov 9, 2026
Merged

anfimovdm merged 2 commits into
AlmaLinux:masterfrom
eabdullin1:build-search-filters

Conversation

@eabdullin1

@eabdullin1 eabdullin1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problems

rpm_* filters are slow. Measured on production (page 1):

query server time
no filter 1.0 s
rpm_name=bash 7.1 s
rpm_name=kernel 73.4 s

_get_pulp_hrefs() collects the hrefs of matching packages through the Pulp REST API, which PulpClient pages through 100 packages per request, and then BuildTaskArtifact.href IN (...) runs in the correlated EXISTS of both the page and the count query, while build_artifacts.href has no index.

project filter matches unrelated builds. It is BuildTaskRef.url LIKE '%/<project>%', and every URL looks like https://git.almalinux.org/rpms/<name>.git, so project=rpm or project=rpms returns every build, and so does project=git (//git.almalinux.org).

Changes

  • rpm_* filters read the hrefs from the Pulp database (pulp_async session, 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.
  • project matches the beginning of the repository or SRPM file name only, i.e. the last part of the URL (url ~ '/<escaped project>[^/]*$'). ch still finds chan, kernel finds kernel and kernel-rt; rpm finds only repositories whose name starts with rpm.

Tests

  • New tests/test_utils/test_pulp_package_hrefs.py runs the Pulp lookup against a real rpm_package table (created in the test database only with the columns the lookup uses): exact names (bash doesn't find bash-doc), combinations of fields, empty values, no matches.
  • test_get_builds_filters got project=ch / rpm / rpms / git / almalinux / han cases; rpm, rpms and git fail on the current code.
  • The rpm_* API tests mock the new lookup instead of PulpClient.get_rpm_packages.
  • Whole suite: 335 passed, 10 skipped (tests/test_oval excluded: 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. The href IN (...) part still runs without an index on build_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 by rpm_arch alone still matches millions of packages and stays slow (it was slower with the API paging).

🤖 Generated with Claude Code

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.
@anfimovdm
anfimovdm merged commit cff8095 into AlmaLinux:master Nov 9, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants