Open
Conversation
This adds a `/build-redirect/$basename` endpoint that redirects to the first build of `/nix/store/$basename`. The first build is determined by taking the minimum of build ID. Currently, the only way to find the build for a store path is using the `/search` endpoint, but a request to that endpoint is so slow it will timeout: ``` $ time curl -H "Accept: application/json" https://hydra.nixos.org/search?query=/nix/store/v02pl5dhayp8jnz8ahdvg5vi71s8xc6g-hello-2.12.1 {"error":"DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: canceling statement due to statement timeout [for Statement \"SELECT me.id, me.finished, me.timestamp, me.jobset_id, me.job, me.nixname, me.description, me.drvpath, me.system, me.license, me.homepage, me.maintainers, me.maxsilent, me.timeout, me.ischannel, me.iscurrent, me.priority, me.globalpriority, me.starttime, me.stoptime, me.iscachedbuild, me.buildstatus, me.size, me.closuresize, me.releasename, me.keep, me.notificationpendingsince FROM builds me LEFT JOIN buildoutputs buildoutputs ON buildoutputs.build = me.id WHERE ( buildoutputs.path ILIKE ? ) ORDER BY id desc LIMIT ?\" with ParamValues: 1='%/nix/store/v02pl5dhayp8jnz8ahdvg5vi71s8xc6g-hello-2.12.1%', 2='10'] at /nix/store/sw39pc6gwfwadr0f3nz6bzsf63qwpcwg-hydra-0.1.20221124.0118770/libexec/hydra/lib/Hydra/Controller/Root.pm line 486\n"} real 0m22.935s user 0m0.070s sys 0m0.019s ``` The new endpoint uses an index on BuildOutputs.path. Here is an explain of the SQL query executed by the new endpoint: ``` hydra=# explain analyze SELECT MIN( me.build ) FROM buildoutputs me WHERE ( path = '...store path...' ); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=12.50..12.51 rows=1 width=4) (actual time=0.024..0.025 rows=1 loops=1) -> Bitmap Heap Scan on buildoutputs me (cost=4.03..12.49 rows=4 width=4) (actual time=0.019..0.020 rows=2 loops=1) Recheck Cond: (path = '...store path...'::text) Heap Blocks: exact=1 -> Bitmap Index Scan on indexbuildoutputspath (cost=0.00..4.03 rows=4 width=0) (actual time=0.010..0.010 rows=2 loops=1) Index Cond: (path = '...store path...'::text) Planning Time: 0.134 ms Execution Time: 0.060 ms (8 rows) ```
Author
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.
This adds a
/build-redirect/$basenameendpoint that redirects to the first build of/nix/store/$basename. The first build is determined by taking the minimum of build ID.Currently, the only way to find the build for a store path is using the
/searchendpoint, but a request to that endpoint is so slow it will timeout:The new endpoint uses an index on BuildOutputs.path. Here is an explain of the SQL query executed by the new endpoint: