From 05c828796514b7bcd8a613da8ab1d6a5402931fa Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 12 Jul 2019 19:52:50 +0100 Subject: [PATCH] Lock around the channel fetch when loading new revisions This is in preparation for running jobs in parallel. The channels code in Guix uses a cached copy of the Git repository. Multiple jobs can't concurrently access this without causing issues, so use an advisory lock to ensure that only one job is using the repository at a time. --- .../jobs/load-new-guix-revision.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 8c53183..401a2c7 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -482,12 +482,18 @@ (close-inferior inferior) #f)))) -(define (channel->manifest-store-item store channel) +(define (channel->manifest-store-item conn store channel) (let* ((manifest-store-item-derivation-file-name (log-time "computing the channel derivation" (lambda () - (channel->derivation-file-name store channel)))) + ;; Obtain a session level lock here, to avoid conflicts with + ;; other jobs over the Git repository. + (with-advisory-session-lock + conn + 'channel->manifest-store-item + (lambda () + (channel->derivation-file-name store channel)))))) (derivation (read-derivation-from-file manifest-store-item-derivation-file-name))) (log-time @@ -496,13 +502,14 @@ (build-derivations store (list derivation)))) (derivation->output-path derivation))) -(define (channel->guix-store-item store channel) +(define (channel->guix-store-item conn store channel) (catch #t (lambda () (dirname (readlink - (string-append (channel->manifest-store-item store + (string-append (channel->manifest-store-item conn + store channel) "/bin")))) (lambda args @@ -573,6 +580,7 @@ (set-build-options store #:fallback? #t) (channel->guix-store-item + conn store (channel (name 'guix) (url (git-repository-id->url