aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-data-service/model/guix-revision-package-derivation.scm47
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