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))
|
||||
(raise-exception exn)))
|
||||
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)
|
||||
;; The order shouldn't matter here, but bugs in Guix can lead to different
|
||||
|
|
@ -1182,29 +1199,7 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
|
|||
(values derivations
|
||||
derivation-ids)))))))
|
||||
|
||||
(let ((derivations
|
||||
derivation-ids
|
||||
(insert-derivations)))
|
||||
|
||||
(unless (null? derivations)
|
||||
(fibers-parallel
|
||||
(derivations-insert-sources postgresql-connection-pool
|
||||
call-with-utility-thread
|
||||
derivations
|
||||
derivation-ids
|
||||
#:log-tag log-tag)
|
||||
(with-time-logging
|
||||
(string-append "insert-missing-derivations: inserting outputs ("
|
||||
log-tag ")")
|
||||
(with-resource-from-pool postgresql-connection-pool conn
|
||||
(vector-for-each
|
||||
(lambda (_ derivation-id derivation)
|
||||
(insert-derivation-outputs conn
|
||||
derivation-id
|
||||
(derivation-outputs derivation)))
|
||||
derivation-ids
|
||||
derivations)))
|
||||
|
||||
(define (insert-input-derivations derivations)
|
||||
(with-time-logging
|
||||
(string-append
|
||||
"insert-missing-derivations: ensure-input-derivations-exist ("
|
||||
|
|
@ -1230,9 +1225,35 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
|
|||
1000
|
||||
input-derivations)))))
|
||||
|
||||
(let ((derivations
|
||||
derivation-ids
|
||||
(insert-derivations)))
|
||||
|
||||
(unless (null? derivations)
|
||||
(fibers-parallel
|
||||
(derivations-insert-sources postgresql-connection-pool
|
||||
call-with-utility-thread
|
||||
derivations
|
||||
derivation-ids
|
||||
#:log-tag log-tag)
|
||||
(with-time-logging
|
||||
(string-append "insert-missing-derivations: inserting outputs ("
|
||||
log-tag ")")
|
||||
(with-resource-from-pool postgresql-connection-pool conn
|
||||
(vector-for-each
|
||||
(lambda (_ derivation-id derivation)
|
||||
(insert-derivation-outputs conn
|
||||
derivation-id
|
||||
(derivation-outputs derivation)))
|
||||
derivation-ids
|
||||
derivations)))
|
||||
(insert-input-derivations derivations))
|
||||
|
||||
(simple-format
|
||||
(current-error-port)
|
||||
"debug: insert-missing-derivations: done parallel (~A)\n" log-tag)
|
||||
(retry-on-missing-derivation-output
|
||||
(lambda ()
|
||||
(with-resource-from-pool postgresql-connection-pool conn
|
||||
(with-time-logging
|
||||
(simple-format
|
||||
|
|
@ -1241,7 +1262,14 @@ SELECT 1 FROM derivation_source_file_nars WHERE derivation_source_file_id = $1"
|
|||
log-tag)
|
||||
(insert-derivation-inputs conn
|
||||
derivation-ids
|
||||
derivations))))))
|
||||
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 (derivation-missing-inputs? conn drv-id)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#:use-module (ice-9 vlist)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (ice-9 exceptions)
|
||||
#:use-module (ice-9 binary-ports)
|
||||
#:use-module (rnrs bytevectors)
|
||||
#:use-module (squee)
|
||||
|
|
@ -73,7 +74,12 @@
|
|||
update-derivation-inputs-statistics
|
||||
vacuum-derivation-inputs-table
|
||||
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)
|
||||
'("arm-linux-gnueabihf"
|
||||
|
|
@ -1128,12 +1134,19 @@ ON CONFLICT DO NOTHING"
|
|||
(vector->list (json-string->scm env_vars)))
|
||||
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
|
||||
(mlambda (conn name path)
|
||||
(match (exec-query
|
||||
conn
|
||||
"
|
||||
SELECT derivation_outputs.id FROM derivation_outputs
|
||||
SELECT derivation_outputs.id
|
||||
FROM derivation_outputs
|
||||
INNER JOIN derivations
|
||||
ON derivation_outputs.derivation_id = derivations.id
|
||||
WHERE derivations.file_name = $1
|
||||
|
|
@ -1143,9 +1156,8 @@ WHERE derivations.file_name = $1
|
|||
(((id))
|
||||
id)
|
||||
(()
|
||||
(error (simple-format
|
||||
#f "cannot find derivation-output with name ~A and path ~A"
|
||||
name path))))))
|
||||
(raise-exception
|
||||
(make-derivation-output-error name path))))))
|
||||
|
||||
(define (select-derivation-outputs-by-derivation-id conn id)
|
||||
(define query
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue