diff options
author | Christopher Baines <mail@cbaines.net> | 2019-11-24 13:37:57 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-11-24 20:18:08 +0000 |
commit | 78695c46a12ea00637b9e793445a5104986dc1aa (patch) | |
tree | 2c705b60786075a1d4663e3ee6a8c299319a2683 | |
parent | 5663235048b7341b378634d083eaae9f13580e07 (diff) | |
download | data-service-78695c46a12ea00637b9e793445a5104986dc1aa.tar data-service-78695c46a12ea00637b9e793445a5104986dc1aa.tar.gz |
Just update the package derivation entries that need updating
Previously, all the entries for the branch were deleted, but not, only the
entries for the branch, that are present in the revision that was loaded will
be deleted. This is more efficient, as it avoids deleting and recreating
entries in the table that shouldn't have changed.
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 7615400..9d0e313 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -957,7 +957,10 @@ ORDER BY packages.name, packages.version" #t) -(define (update-package-derivations-table conn git-repository-id commit) +(define (update-package-derivations-table conn + git-repository-id + guix-revision-id + commit) ;; Lock the table to wait for other transactions to commit before updating ;; the table (exec-query @@ -976,9 +979,18 @@ LOCK TABLE ONLY package_derivations_by_guix_revision_range conn " DELETE FROM package_derivations_by_guix_revision_range -WHERE git_repository_id = $1 AND branch_name = $2" +WHERE git_repository_id = $1 AND + branch_name = $2 AND + derivation_id IN ( + SELECT package_derivations.derivation_id + FROM package_derivations + INNER JOIN guix_revision_package_derivations + ON package_derivations.id = guix_revision_package_derivations.package_derivation_id + WHERE revision_id = $3 + )" (list git-repository-id - branch-name)))) + branch-name + guix-revision-id)))) (log-time (simple-format #f "inserting package derivation entries for ~A" branch-name) (lambda () @@ -1011,14 +1023,21 @@ INNER JOIN ( ) AS revision_packages ON packages.id = revision_packages.package_id INNER JOIN guix_revisions ON revision_packages.revision_id = guix_revisions.id INNER JOIN git_branches ON guix_revisions.commit = git_branches.commit -WHERE git_branches.name = $2 +WHERE git_branches.name = $2 AND + revision_packages.derivation_id IN ( + SELECT package_derivations.derivation_id + FROM package_derivations + INNER JOIN guix_revision_package_derivations + ON package_derivations.id = guix_revision_package_derivations.package_derivation_id + WHERE revision_id = $3 + ) WINDOW package_version AS ( PARTITION BY packages.name, packages.version, revision_packages.derivation_id ORDER BY git_branches.datetime RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) ORDER BY packages.name, packages.version" - (list git-repository-id branch-name)))))) + (list git-repository-id branch-name guix-revision-id)))))) (exec-query conn "SELECT name FROM git_branches WHERE commit = $1 AND git_repository_id = $2" @@ -1060,7 +1079,10 @@ ORDER BY packages.name, packages.version" (extract-information-from conn guix-revision-id commit store-item) (update-package-versions-table conn git-repository-id commit) - (update-package-derivations-table conn git-repository-id commit))) + (update-package-derivations-table conn + git-repository-id + guix-revision-id + commit))) (begin (simple-format #t "Failed to generate store item for ~A\n" commit) |