Try to address the issue of missing derivation outputs
This commit is contained in:
parent
1181b13ffe
commit
b904fdb161
2 changed files with 80 additions and 40 deletions
|
|
@ -135,7 +135,24 @@
|
||||||
#:on-exception on-exception))
|
#:on-exception on-exception))
|
||||||
(raise-exception exn)))
|
(raise-exception exn)))
|
||||||
thunk
|
thunk
|
||||||
#:unwind? #t))
|
#:unwind? #t
|
||||||
|
#:unwind-for-type &missing-store-item-error))
|
||||||
|
|
||||||
|
(define* (retry-on-missing-derivation-output thunk #:key on-exception)
|
||||||
|
(with-exception-handler
|
||||||
|
(lambda (exn)
|
||||||
|
(simple-format (current-error-port)
|
||||||
|
"missing derivation output ~A ~A, retrying ~A\n"
|
||||||
|
(missing-derivation-output-error-name exn)
|
||||||
|
(missing-derivation-output-error-path exn)
|
||||||
|
thunk)
|
||||||
|
(when on-exception (on-exception))
|
||||||
|
(retry-on-missing-store-item
|
||||||
|
thunk
|
||||||
|
#:on-exception on-exception))
|
||||||
|
thunk
|
||||||
|
#:unwind? #t
|
||||||
|
#:unwind-for-type &missing-derivation-output-error))
|
||||||
|
|
||||||
(define (inferior-guix-systems inf)
|
(define (inferior-guix-systems inf)
|
||||||
;; The order shouldn't matter here, but bugs in Guix can lead to different
|
;; The order shouldn't matter here, but bugs in Guix can lead to different
|
||||||
|
|
@ -1182,6 +1199,32 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
|
||||||
(values derivations
|
(values derivations
|
||||||
derivation-ids)))))))
|
derivation-ids)))))))
|
||||||
|
|
||||||
|
(define (insert-input-derivations derivations)
|
||||||
|
(with-time-logging
|
||||||
|
(string-append
|
||||||
|
"insert-missing-derivations: ensure-input-derivations-exist ("
|
||||||
|
log-tag ")")
|
||||||
|
(let ((input-derivations
|
||||||
|
(vector-fold
|
||||||
|
(lambda (_ result drv)
|
||||||
|
(append! (map derivation-input-derivation
|
||||||
|
(derivation-inputs drv))
|
||||||
|
result))
|
||||||
|
'()
|
||||||
|
derivations)))
|
||||||
|
(unless (null? input-derivations)
|
||||||
|
;; Ensure all the input derivations exist
|
||||||
|
(chunk-for-each!
|
||||||
|
(lambda (chunk)
|
||||||
|
(insert-missing-derivations
|
||||||
|
postgresql-connection-pool
|
||||||
|
call-with-utility-thread
|
||||||
|
derivation-ids-hash-table
|
||||||
|
chunk
|
||||||
|
#:log-tag log-tag))
|
||||||
|
1000
|
||||||
|
input-derivations)))))
|
||||||
|
|
||||||
(let ((derivations
|
(let ((derivations
|
||||||
derivation-ids
|
derivation-ids
|
||||||
(insert-derivations)))
|
(insert-derivations)))
|
||||||
|
|
@ -1204,44 +1247,29 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
|
||||||
(derivation-outputs derivation)))
|
(derivation-outputs derivation)))
|
||||||
derivation-ids
|
derivation-ids
|
||||||
derivations)))
|
derivations)))
|
||||||
|
(insert-input-derivations derivations))
|
||||||
(with-time-logging
|
|
||||||
(string-append
|
|
||||||
"insert-missing-derivations: ensure-input-derivations-exist ("
|
|
||||||
log-tag ")")
|
|
||||||
(let ((input-derivations
|
|
||||||
(vector-fold
|
|
||||||
(lambda (_ result drv)
|
|
||||||
(append! (map derivation-input-derivation
|
|
||||||
(derivation-inputs drv))
|
|
||||||
result))
|
|
||||||
'()
|
|
||||||
derivations)))
|
|
||||||
(unless (null? input-derivations)
|
|
||||||
;; Ensure all the input derivations exist
|
|
||||||
(chunk-for-each!
|
|
||||||
(lambda (chunk)
|
|
||||||
(insert-missing-derivations
|
|
||||||
postgresql-connection-pool
|
|
||||||
call-with-utility-thread
|
|
||||||
derivation-ids-hash-table
|
|
||||||
chunk
|
|
||||||
#:log-tag log-tag))
|
|
||||||
1000
|
|
||||||
input-derivations)))))
|
|
||||||
|
|
||||||
(simple-format
|
(simple-format
|
||||||
(current-error-port)
|
(current-error-port)
|
||||||
"debug: insert-missing-derivations: done parallel (~A)\n" log-tag)
|
"debug: insert-missing-derivations: done parallel (~A)\n" log-tag)
|
||||||
(with-resource-from-pool postgresql-connection-pool conn
|
(retry-on-missing-derivation-output
|
||||||
(with-time-logging
|
(lambda ()
|
||||||
(simple-format
|
(with-resource-from-pool postgresql-connection-pool conn
|
||||||
#f "insert-missing-derivations: inserting inputs for ~A derivations (~A)"
|
(with-time-logging
|
||||||
(vector-length derivations)
|
(simple-format
|
||||||
log-tag)
|
#f "insert-missing-derivations: inserting inputs for ~A derivations (~A)"
|
||||||
(insert-derivation-inputs conn
|
(vector-length derivations)
|
||||||
derivation-ids
|
log-tag)
|
||||||
derivations))))))
|
(insert-derivation-inputs conn
|
||||||
|
derivation-ids
|
||||||
|
derivations))))
|
||||||
|
#:on-exception
|
||||||
|
(lambda ()
|
||||||
|
;; If this has happened because derivations have been removed, it
|
||||||
|
;; might be necessary to insert them in the database where they
|
||||||
|
;; previously existed
|
||||||
|
(hash-clear! derivation-ids-hash-table)
|
||||||
|
(insert-input-derivations derivations))))))
|
||||||
|
|
||||||
(define (fix-derivation file-name)
|
(define (fix-derivation file-name)
|
||||||
(define (derivation-missing-inputs? conn drv-id)
|
(define (derivation-missing-inputs? conn drv-id)
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#:use-module (ice-9 vlist)
|
#:use-module (ice-9 vlist)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 format)
|
#:use-module (ice-9 format)
|
||||||
|
#:use-module (ice-9 exceptions)
|
||||||
#:use-module (ice-9 binary-ports)
|
#:use-module (ice-9 binary-ports)
|
||||||
#:use-module (rnrs bytevectors)
|
#:use-module (rnrs bytevectors)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
|
|
@ -73,7 +74,12 @@
|
||||||
update-derivation-inputs-statistics
|
update-derivation-inputs-statistics
|
||||||
vacuum-derivation-inputs-table
|
vacuum-derivation-inputs-table
|
||||||
update-derivation-outputs-statistics
|
update-derivation-outputs-statistics
|
||||||
vacuum-derivation-outputs-table))
|
vacuum-derivation-outputs-table
|
||||||
|
|
||||||
|
&missing-derivation-output-error
|
||||||
|
missing-derivation-output-error?
|
||||||
|
missing-derivation-output-error-name
|
||||||
|
missing-derivation-output-error-path))
|
||||||
|
|
||||||
(define (valid-targets conn)
|
(define (valid-targets conn)
|
||||||
'("arm-linux-gnueabihf"
|
'("arm-linux-gnueabihf"
|
||||||
|
|
@ -1128,12 +1134,19 @@ ON CONFLICT DO NOTHING"
|
||||||
(vector->list (json-string->scm env_vars)))
|
(vector->list (json-string->scm env_vars)))
|
||||||
system))))
|
system))))
|
||||||
|
|
||||||
|
(define-exception-type &missing-derivation-output-error &error
|
||||||
|
make-derivation-output-error
|
||||||
|
missing-derivation-output-error?
|
||||||
|
(name missing-derivation-output-error-name)
|
||||||
|
(path missing-derivation-output-error-path))
|
||||||
|
|
||||||
(define select-derivation-output-id
|
(define select-derivation-output-id
|
||||||
(mlambda (conn name path)
|
(mlambda (conn name path)
|
||||||
(match (exec-query
|
(match (exec-query
|
||||||
conn
|
conn
|
||||||
"
|
"
|
||||||
SELECT derivation_outputs.id FROM derivation_outputs
|
SELECT derivation_outputs.id
|
||||||
|
FROM derivation_outputs
|
||||||
INNER JOIN derivations
|
INNER JOIN derivations
|
||||||
ON derivation_outputs.derivation_id = derivations.id
|
ON derivation_outputs.derivation_id = derivations.id
|
||||||
WHERE derivations.file_name = $1
|
WHERE derivations.file_name = $1
|
||||||
|
|
@ -1143,9 +1156,8 @@ WHERE derivations.file_name = $1
|
||||||
(((id))
|
(((id))
|
||||||
id)
|
id)
|
||||||
(()
|
(()
|
||||||
(error (simple-format
|
(raise-exception
|
||||||
#f "cannot find derivation-output with name ~A and path ~A"
|
(make-derivation-output-error name path))))))
|
||||||
name path))))))
|
|
||||||
|
|
||||||
(define (select-derivation-outputs-by-derivation-id conn id)
|
(define (select-derivation-outputs-by-derivation-id conn id)
|
||||||
(define query
|
(define query
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue