Use a more long lived store connection for loading data

As this will enable registering temporary roots, to avoid store items being
garbage collected.
This commit is contained in:
Christopher Baines 2020-02-13 19:38:20 +00:00
parent 32052c45b3
commit 0ef3349ed8
2 changed files with 212 additions and 214 deletions

View file

@ -715,7 +715,7 @@ WHERE job_id = $1"
(build-derivations store (list derivation))))
(derivation->output-path derivation)))
(define (channel->derivation-file-names-by-system channel)
(define (channel->derivation-file-names-by-system store channel)
(define use-container? (defined?
'open-inferior/container
(resolve-module '(guix inferior))))
@ -780,9 +780,6 @@ WHERE job_id = $1"
#f))))))))
(list ,@systems)))))
(with-store store
(set-build-options store #:fallback? #t)
(let ((inferior
(if use-container?
(open-inferior/container
@ -854,9 +851,9 @@ WHERE job_id = $1"
key parameters))))
(lambda args
(close-inferior inferior)
#f)))))
#f))))
(define (channel->derivations-by-system conn channel)
(define (channel->derivations-by-system conn store channel)
(let* ((derivation-file-names-by-system
(log-time
"computing the channel derivation"
@ -867,7 +864,7 @@ WHERE job_id = $1"
conn
'channel->manifest-store-item
(lambda ()
(channel->derivation-file-names-by-system channel)))))))
(channel->derivation-file-names-by-system store channel)))))))
(for-each
(match-lambda
((system . derivation-file-name)
@ -880,6 +877,7 @@ WHERE job_id = $1"
derivation-file-names-by-system))
(define (channel-derivations-by-system->guix-store-item
store
channel-derivations-by-system)
(define (store-item->guix-store-item filename)
@ -895,13 +893,10 @@ WHERE job_id = $1"
(if derivation-file-name-for-current-system
(let ((derivation-for-current-system
(read-derivation-from-file derivation-file-name-for-current-system)))
(with-store store
(set-build-options store #:fallback? #t)
(log-time
"building the channel derivation"
(lambda ()
(build-derivations store (list derivation-for-current-system)))))
(build-derivations store (list derivation-for-current-system))))
(store-item->guix-store-item
(derivation->output-path derivation-for-current-system)))
@ -939,13 +934,8 @@ WHERE job_id = $1"
output)))
(define (extract-information-from conn guix-revision-id commit store-path)
(simple-format
#t "debug: extract-information-from: ~A\n" store-path)
(with-store store
(set-build-options store
#:fallback? #t)
(define (extract-information-from conn store guix-revision-id commit store-path)
(simple-format #t "debug: extract-information-from: ~A\n" store-path)
(let* ((guix-locpath (getenv "GUIX_LOCPATH"))
(inf (let ((guix-locpath
;; Augment the GUIX_LOCPATH to include glibc-locales from
@ -1118,7 +1108,7 @@ WHERE job_id = $1"
" ~A ~A\n\n" key args)
#f)
(lambda (key . args)
(display-backtrace (make-stack #t) (current-error-port)))))))
(display-backtrace (make-stack #t) (current-error-port))))))
(define (update-package-versions-table conn git-repository-id commit)
(log-time
@ -1186,7 +1176,7 @@ ORDER BY packages.name, packages.version"
#t)
(define (load-new-guix-revision conn git-repository-id commit)
(define (load-new-guix-revision conn store git-repository-id commit)
(let* ((channel-for-commit
(channel (name 'guix)
(url (git-repository-id->url
@ -1195,9 +1185,11 @@ ORDER BY packages.name, packages.version"
(commit commit)))
(channel-derivations-by-system
(channel->derivations-by-system conn
store
channel-for-commit))
(store-item
(channel-derivations-by-system->guix-store-item
store
channel-derivations-by-system)))
(if store-item
(let ((guix-revision-id
@ -1205,7 +1197,8 @@ ORDER BY packages.name, packages.version"
commit store-item)))
(and
guix-revision-id
(extract-information-from conn guix-revision-id
(extract-information-from conn store
guix-revision-id
commit store-item)
(insert-channel-instances conn
guix-revision-id
@ -1524,8 +1517,10 @@ SKIP LOCKED")
(simple-format #t "Processing job ~A (commit: ~A, source: ~A)\n\n"
id commit source)
(if (or (guix-revision-exists? conn git-repository-id commit)
(eq? (log-time
(if (or
(guix-revision-exists? conn git-repository-id commit)
(eq?
(log-time
(string-append "loading revision " commit)
(lambda ()
(let* ((previous-output-port (current-output-port))
@ -1543,9 +1538,12 @@ SKIP LOCKED")
(real-error-port previous-error-port))
(catch #t
(lambda ()
(with-store store
(set-build-options store #:fallback? #t)
(load-new-guix-revision conn
store
git-repository-id
commit))
commit)))
(lambda (key . args)
(simple-format
(current-error-port)

View file

@ -25,7 +25,7 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel->derivations-by-system
(lambda (conn channel)
(lambda (conn store channel)
'((x86_64-linux
.
((manifest-entry-item . /gnu/store/foo.drv)
@ -34,13 +34,13 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel-derivations-by-system->guix-store-item
(lambda (channel-derivations-by-system)
(lambda (store channel-derivations-by-system)
"/gnu/store/test"))
(mock
((guix-data-service jobs load-new-guix-revision)
extract-information-from
(lambda (conn guix-revision-id commit store-path)
(lambda (conn store guix-revision-id commit store-path)
#t))
(mock
@ -71,7 +71,7 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel->derivations-by-system
(lambda (conn channel)
(lambda (conn store channel)
'(x86_64-linux
.
((manifest-entry-item . /gnu/store/foo.drv)
@ -80,7 +80,7 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel-derivations-by-system->guix-store-item
(lambda (channel-derivations-by-system)
(lambda (store channel-derivations-by-system)
#f))
(match (enqueue-load-new-guix-revision-job
@ -98,7 +98,7 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel->derivations-by-system
(lambda (conn channel)
(lambda (conn store channel)
'(x86_64-linux
.
((manifest-entry-item . /gnu/store/foo.drv)
@ -107,13 +107,13 @@
(mock
((guix-data-service jobs load-new-guix-revision)
channel-derivations-by-system->guix-store-item
(lambda (channel-derivations-by-system)
(lambda (store channel-derivations-by-system)
"/gnu/store/test"))
(mock
((guix-data-service jobs load-new-guix-revision)
extract-information-from
(lambda (conn git-repository-id commit store-path)
(lambda (conn store git-repository-id commit store-path)
#f))
(mock