Better handle retries for jobs
This was broken when the guix_revisions entry started being added before the final commit.
This commit is contained in:
parent
7fbcb3a3c2
commit
643753ff46
|
@ -1316,20 +1316,32 @@ WHERE job_id = $1"
|
|||
store
|
||||
channel-for-commit
|
||||
fetch-with-authentication?)))
|
||||
(let ((guix-revision-id
|
||||
(insert-guix-revision conn git-repository-id commit)))
|
||||
(insert-channel-instances conn
|
||||
guix-revision-id
|
||||
(filter-map
|
||||
(match-lambda
|
||||
((system . derivations)
|
||||
(and=>
|
||||
(assoc-ref derivations
|
||||
'manifest-entry-item)
|
||||
(lambda (drv)
|
||||
(cons system drv)))))
|
||||
channel-derivations-by-system))
|
||||
|
||||
(with-time-logging
|
||||
"acquiring advisory transaction lock: load-new-guix-revision-inserts"
|
||||
;; Wait until this is the only transaction inserting data, to avoid any
|
||||
;; concurrency issues
|
||||
(obtain-advisory-transaction-lock conn
|
||||
'load-new-guix-revision-inserts))
|
||||
(let* ((existing-guix-revision-id
|
||||
(git-repository-id-and-commit->revision-id conn
|
||||
git-repository-id
|
||||
commit))
|
||||
(guix-revision-id
|
||||
(or existing-guix-revision-id
|
||||
(insert-guix-revision conn git-repository-id commit))))
|
||||
(unless existing-guix-revision-id
|
||||
(insert-channel-instances conn
|
||||
guix-revision-id
|
||||
(filter-map
|
||||
(match-lambda
|
||||
((system . derivations)
|
||||
(and=>
|
||||
(assoc-ref derivations
|
||||
'manifest-entry-item)
|
||||
(lambda (drv)
|
||||
(cons system drv)))))
|
||||
channel-derivations-by-system)))
|
||||
(simple-format
|
||||
(current-error-port)
|
||||
"guix-data-service: saving the channel instance derivations to the database\n")
|
||||
|
@ -1777,32 +1789,30 @@ 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?
|
||||
(with-time-logging (string-append "loading revision " commit)
|
||||
(setup-logging
|
||||
id
|
||||
(lambda ()
|
||||
(with-exception-handler
|
||||
(const #f)
|
||||
(lambda ()
|
||||
(with-exception-handler
|
||||
(lambda (exn)
|
||||
(simple-format (current-error-port)
|
||||
"error: load-new-guix-revision: ~A\n"
|
||||
exn)
|
||||
(backtrace)
|
||||
#f)
|
||||
(lambda ()
|
||||
(with-store-connection
|
||||
(lambda (store)
|
||||
(load-new-guix-revision conn
|
||||
store
|
||||
git-repository-id
|
||||
commit))))))
|
||||
#:unwind? #t))))
|
||||
#t))
|
||||
(if (eq?
|
||||
(with-time-logging (string-append "loading revision " commit)
|
||||
(setup-logging
|
||||
id
|
||||
(lambda ()
|
||||
(with-exception-handler
|
||||
(const #f)
|
||||
(lambda ()
|
||||
(with-exception-handler
|
||||
(lambda (exn)
|
||||
(simple-format (current-error-port)
|
||||
"error: load-new-guix-revision: ~A\n"
|
||||
exn)
|
||||
(backtrace)
|
||||
#f)
|
||||
(lambda ()
|
||||
(with-store-connection
|
||||
(lambda (store)
|
||||
(load-new-guix-revision conn
|
||||
store
|
||||
git-repository-id
|
||||
commit))))))
|
||||
#:unwind? #t))))
|
||||
#t)
|
||||
(begin
|
||||
(record-job-succeeded conn id)
|
||||
(record-job-event conn id "success")
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#:export (count-guix-revisions
|
||||
most-recent-n-guix-revisions
|
||||
commit->revision-id
|
||||
git-repository-id-and-commit->revision-id
|
||||
insert-guix-revision
|
||||
guix-commit-exists?
|
||||
guix-revision-exists?
|
||||
|
@ -46,6 +47,19 @@
|
|||
id)
|
||||
(() #f)))
|
||||
|
||||
(define (git-repository-id-and-commit->revision-id conn git-repository-id commit)
|
||||
(match (exec-query
|
||||
conn
|
||||
"
|
||||
SELECT id
|
||||
FROM guix_revisions
|
||||
WHERE commit = $1
|
||||
AND git_repository_id = $2"
|
||||
(list commit git-repository-id))
|
||||
(((id))
|
||||
id)
|
||||
(() #f)))
|
||||
|
||||
(define (insert-guix-revision conn git-repository-id commit)
|
||||
(define insert
|
||||
"
|
||||
|
|
Loading…
Reference in New Issue