From f23223f16d8f532a60824d88a45deaa23ec43be2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 28 Feb 2020 20:40:31 +0000 Subject: [PATCH] Improve the locking around fetching channel instances I think there's still the potential for a race condition when working with the cached checkout of the repository, but this lock was far too wide. The sensitive section is just the latest-channel-instances call, as it adds the relevant files to the store, and that's what's returned. --- .../jobs/load-new-guix-revision.scm | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 8c154eb..0f9cbba 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -750,7 +750,7 @@ WHERE job_id = $1" (build-derivations store (list derivation))) (derivation->output-path derivation))) -(define (channel->derivation-file-names-by-system store channel) +(define (channel->derivation-file-names-by-system conn store channel) (define use-container? (defined? 'open-inferior/container (resolve-module '(guix inferior)))) @@ -852,9 +852,15 @@ WHERE job_id = $1" inferior)) (let ((channel-instance - (first - (latest-channel-instances store - (list channel))))) + ;; Obtain a session level lock here, to avoid conflicts with + ;; other jobs over the Git repository. + (with-advisory-session-lock/log-time + conn + 'latest-channel-instances + (lambda () + (first + (latest-channel-instances store + (list channel))))))) (inferior-eval '(use-modules (srfi srfi-1) (guix channels) (guix grafts) @@ -897,13 +903,7 @@ WHERE job_id = $1" (define (channel->derivations-by-system conn store channel) (let* ((derivation-file-names-by-system (with-time-logging "computing the channel derivation" - ;; Obtain a session level lock here, to avoid conflicts with - ;; other jobs over the Git repository. - (with-advisory-session-lock/log-time - conn - 'channel->manifest-store-item - (lambda () - (channel->derivation-file-names-by-system store channel)))))) + (channel->derivation-file-names-by-system conn store channel)))) (for-each (match-lambda ((system . derivation-file-name)