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
2 changed files with 63 additions and 39 deletions
|
|
@ -1316,8 +1316,21 @@ WHERE job_id = $1"
|
||||||
store
|
store
|
||||||
channel-for-commit
|
channel-for-commit
|
||||||
fetch-with-authentication?)))
|
fetch-with-authentication?)))
|
||||||
(let ((guix-revision-id
|
|
||||||
(insert-guix-revision conn git-repository-id commit)))
|
(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
|
(insert-channel-instances conn
|
||||||
guix-revision-id
|
guix-revision-id
|
||||||
(filter-map
|
(filter-map
|
||||||
|
|
@ -1328,8 +1341,7 @@ WHERE job_id = $1"
|
||||||
'manifest-entry-item)
|
'manifest-entry-item)
|
||||||
(lambda (drv)
|
(lambda (drv)
|
||||||
(cons system drv)))))
|
(cons system drv)))))
|
||||||
channel-derivations-by-system))
|
channel-derivations-by-system)))
|
||||||
|
|
||||||
(simple-format
|
(simple-format
|
||||||
(current-error-port)
|
(current-error-port)
|
||||||
"guix-data-service: saving the channel instance derivations to the database\n")
|
"guix-data-service: saving the channel instance derivations to the database\n")
|
||||||
|
|
@ -1777,9 +1789,7 @@ SKIP LOCKED")
|
||||||
(simple-format #t "Processing job ~A (commit: ~A, source: ~A)\n\n"
|
(simple-format #t "Processing job ~A (commit: ~A, source: ~A)\n\n"
|
||||||
id commit source)
|
id commit source)
|
||||||
|
|
||||||
(if (or
|
(if (eq?
|
||||||
(guix-revision-exists? conn git-repository-id commit)
|
|
||||||
(eq?
|
|
||||||
(with-time-logging (string-append "loading revision " commit)
|
(with-time-logging (string-append "loading revision " commit)
|
||||||
(setup-logging
|
(setup-logging
|
||||||
id
|
id
|
||||||
|
|
@ -1802,7 +1812,7 @@ SKIP LOCKED")
|
||||||
git-repository-id
|
git-repository-id
|
||||||
commit))))))
|
commit))))))
|
||||||
#:unwind? #t))))
|
#:unwind? #t))))
|
||||||
#t))
|
#t)
|
||||||
(begin
|
(begin
|
||||||
(record-job-succeeded conn id)
|
(record-job-succeeded conn id)
|
||||||
(record-job-event conn id "success")
|
(record-job-event conn id "success")
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#:export (count-guix-revisions
|
#:export (count-guix-revisions
|
||||||
most-recent-n-guix-revisions
|
most-recent-n-guix-revisions
|
||||||
commit->revision-id
|
commit->revision-id
|
||||||
|
git-repository-id-and-commit->revision-id
|
||||||
insert-guix-revision
|
insert-guix-revision
|
||||||
guix-commit-exists?
|
guix-commit-exists?
|
||||||
guix-revision-exists?
|
guix-revision-exists?
|
||||||
|
|
@ -46,6 +47,19 @@
|
||||||
id)
|
id)
|
||||||
(() #f)))
|
(() #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-guix-revision conn git-repository-id commit)
|
||||||
(define insert
|
(define insert
|
||||||
"
|
"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue