diff options
author | Christopher Baines <mail@cbaines.net> | 2024-08-10 21:07:35 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-08-12 09:14:36 +0100 |
commit | 4d0813c3318bf59eae485817ede6facd0d0b4eee (patch) | |
tree | 5a05f00ed7ed2de88ab5f83009d13ea6fc469765 | |
parent | b79c7e83be03be8f420e9f78ac3f8d9000c17f77 (diff) | |
download | data-service-4d0813c3318bf59eae485817ede6facd0d0b4eee.tar data-service-4d0813c3318bf59eae485817ede6facd0d0b4eee.tar.gz |
Add more logging to backfilling guix_revision_package_derivation_distribution_counts
-rw-r--r-- | guix-data-service/model/guix-revision-package-derivation.scm | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/guix-data-service/model/guix-revision-package-derivation.scm b/guix-data-service/model/guix-revision-package-derivation.scm index 99a7079..733cf34 100644 --- a/guix-data-service/model/guix-revision-package-derivation.scm +++ b/guix-data-service/model/guix-revision-package-derivation.scm @@ -20,6 +20,7 @@ #:use-module (ice-9 threads) #:use-module (squee) #:use-module (guix-data-service database) + #:use-module (guix-data-service utils) #:use-module (guix-data-service model system) #:export (insert-guix-revision-package-derivations @@ -174,30 +175,40 @@ ORDER BY id DESC"))) (for-each (lambda (revision-id) - (simple-format #t "backfilling guix_revision_package_derivation_distribution_counts for revision ~A\n" revision-id) - (let ((system-ids-and-targets - (exec-query - conn - " + (with-exception-handler + (lambda (exn) + (simple-format + #t "exception backfilling guix_revision_package_derivation_distribution_counts for revision ~A: ~A\n" + revision-id exn)) + (lambda () + (with-time-logging + (simple-format + #f "backfilling guix_revision_package_derivation_distribution_counts for revision ~A" + revision-id) + (let ((system-ids-and-targets + (exec-query + conn + " SELECT DISTINCT system_id, target FROM package_derivations INNER JOIN guix_revision_package_derivations ON package_derivations.id = guix_revision_package_derivations.package_derivation_id WHERE revision_id = $1" - (list revision-id)))) + (list revision-id)))) - (with-postgresql-transaction - conn - (lambda (conn) - (for-each - (match-lambda - ((system-id target) - (insert-guix-revision-package-derivation-distribution-counts - conn - revision-id - system-id - target))) - system-ids-and-targets))))) + (with-postgresql-transaction + conn + (lambda (conn) + (for-each + (match-lambda + ((system-id target) + (insert-guix-revision-package-derivation-distribution-counts + conn + revision-id + system-id + target))) + system-ids-and-targets)))))) + #:unwind? #t)) revision-ids)) (define* (get-sql-to-select-package-and-related-derivations-for-revision |