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.
This commit is contained in:
Christopher Baines 2019-07-12 19:52:50 +01:00
parent fde1000cb3
commit 05c8287965

View file

@ -482,12 +482,18 @@
(close-inferior inferior) (close-inferior inferior)
#f)))) #f))))
(define (channel->manifest-store-item store channel) (define (channel->manifest-store-item conn store channel)
(let* ((manifest-store-item-derivation-file-name (let* ((manifest-store-item-derivation-file-name
(log-time (log-time
"computing the channel derivation" "computing the channel derivation"
(lambda () (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 (derivation
(read-derivation-from-file manifest-store-item-derivation-file-name))) (read-derivation-from-file manifest-store-item-derivation-file-name)))
(log-time (log-time
@ -496,13 +502,14 @@
(build-derivations store (list derivation)))) (build-derivations store (list derivation))))
(derivation->output-path derivation))) (derivation->output-path derivation)))
(define (channel->guix-store-item store channel) (define (channel->guix-store-item conn store channel)
(catch (catch
#t #t
(lambda () (lambda ()
(dirname (dirname
(readlink (readlink
(string-append (channel->manifest-store-item store (string-append (channel->manifest-store-item conn
store
channel) channel)
"/bin")))) "/bin"))))
(lambda args (lambda args
@ -573,6 +580,7 @@
(set-build-options store (set-build-options store
#:fallback? #t) #:fallback? #t)
(channel->guix-store-item (channel->guix-store-item
conn
store store
(channel (name 'guix) (channel (name 'guix)
(url (git-repository-id->url (url (git-repository-id->url