Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/hydra
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1be7de15a8be
Choose a base ref
...
head repository: NixOS/hydra
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2b4658b6eaee
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Jun 5, 2019

  1. Allow to search builds by hash

    Currently, a full store path has to be provided to search in
    builds. This patch permits to search jobs with a output path or
    derivation hash.
    
    Usecase: we are building Docker images with Hydra. The tag of the
    Docker image is the hash of the image output path. This patch would
    allow us to find back the build job from the tag of a running
    container image.
    nlewo committed Jun 5, 2019
    Copy the full SHA
    778fc03 View commit details

Commits on Jun 6, 2019

  1. Create a pg_trgm index on builds.drvpath

    The search query uses the LIKE operator which requires a sequential
    scan (it can't use the already existing B-tree index). This new
    index (trigram) avoids a sequential scan of the builds table when the
    LIKE operator is used.
    
    Here is the analyze of a request on the builds table with this index:
    
         explain analyze select * from builds where drvpath like '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%';
                                                                     QUERY PLAN
         -----------------------------------------------------------------------------------------------------------------------------------
          Bitmap Heap Scan on builds  (cost=128.00..132.01 rows=1 width=492) (actual time=0.070..0.077 rows=1 loops=1)
            Recheck Cond: (drvpath ~~ '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%'::text)
            ->  Bitmap Index Scan on indextrgmbuildsondrvpath  (cost=0.00..128.00 rows=1 width=0) (actual time=0.047..0.047 rows=3 loops=1)
                  Index Cond: (drvpath ~~ '%k3r71gz0gv16ld8rhcp2bb8gb5w1xc4b%'::text)
          Total runtime: 0.206 ms
         (5 rows)
    nlewo committed Jun 6, 2019
    Copy the full SHA
    7935cff View commit details

Commits on Jun 13, 2019

  1. Merge pull request #654 from nlewo/lewo-search-by-hash

    Allow to search builds by hash
    edolstra authored Jun 13, 2019
    Copy the full SHA
    2b4658b View commit details
Showing with 10 additions and 2 deletions.
  1. +2 −2 src/lib/Hydra/Controller/Root.pm
  2. +6 −0 src/sql/hydra.sql
  3. +2 −0 src/sql/upgrade-57.sql
4 changes: 2 additions & 2 deletions src/lib/Hydra/Controller/Root.pm
Original file line number Diff line number Diff line change
@@ -422,11 +422,11 @@ sub search :Local Args(0) {

# Perform build search in separate queries to prevent seq scan on buildoutputs table.
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
{ "buildoutputs.path" => trim($query) },
{ "buildoutputs.path" => { ilike => "%$query%" } },
{ order_by => ["id desc"], join => ["buildoutputs"] } ) ];

$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
{ "drvpath" => trim($query) },
{ "drvpath" => { ilike => "%$query%" } },
{ order_by => ["id desc"] } ) ];

$c->stash->{resource} = { projects => $c->stash->{projects},
6 changes: 6 additions & 0 deletions src/sql/hydra.sql
Original file line number Diff line number Diff line change
@@ -688,3 +688,9 @@ create index IndexBuildsOnKeep on Builds(keep) where keep = 1;
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1;

create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null;

#ifdef POSTGRESQL
-- Provide an index used by LIKE operator on builds.drvpath (search query)
CREATE EXTENSION pg_trgm;
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);
#endif
2 changes: 2 additions & 0 deletions src/sql/upgrade-57.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE EXTENSION pg_trgm;
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);