Fix dropping the job lock
This commit is contained in:
parent
02b75d857a
commit
07f903abaf
1 changed files with 76 additions and 64 deletions
|
|
@ -1302,6 +1302,50 @@ WHERE job_id = $1")
|
||||||
|
|
||||||
(prevent-inlining-for-tests extract-information-from)
|
(prevent-inlining-for-tests extract-information-from)
|
||||||
|
|
||||||
|
(define (load-channel-instances git-repository-id commit
|
||||||
|
channel-derivations-by-system)
|
||||||
|
;; Load the channel instances in a different transaction, so that this can
|
||||||
|
;; commit prior to the outer transaction
|
||||||
|
(with-postgresql-connection
|
||||||
|
"load-new-guix-revision insert channel instances"
|
||||||
|
(lambda (channel-instances-conn)
|
||||||
|
(with-postgresql-transaction
|
||||||
|
channel-instances-conn
|
||||||
|
(lambda (channel-instances-conn)
|
||||||
|
|
||||||
|
(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 channel-instances-conn
|
||||||
|
'load-new-guix-revision-inserts))
|
||||||
|
|
||||||
|
(let* ((existing-guix-revision-id
|
||||||
|
(git-repository-id-and-commit->revision-id channel-instances-conn
|
||||||
|
git-repository-id
|
||||||
|
commit))
|
||||||
|
(guix-revision-id
|
||||||
|
(or existing-guix-revision-id
|
||||||
|
(insert-guix-revision channel-instances-conn
|
||||||
|
git-repository-id commit))))
|
||||||
|
(unless existing-guix-revision-id
|
||||||
|
(insert-channel-instances 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: saved the channel instance derivations to the database\n"))
|
||||||
|
|
||||||
|
guix-revision-id))))))
|
||||||
|
|
||||||
(define (load-new-guix-revision conn store git-repository-id commit)
|
(define (load-new-guix-revision conn store git-repository-id commit)
|
||||||
(let* ((git-repository-fields
|
(let* ((git-repository-fields
|
||||||
(select-git-repository conn git-repository-id))
|
(select-git-repository conn git-repository-id))
|
||||||
|
|
@ -1317,72 +1361,40 @@ WHERE job_id = $1")
|
||||||
(channel->derivations-by-system conn
|
(channel->derivations-by-system conn
|
||||||
store
|
store
|
||||||
channel-for-commit
|
channel-for-commit
|
||||||
fetch-with-authentication?)))
|
fetch-with-authentication?))
|
||||||
|
(guix-revision-id
|
||||||
|
(load-channel-instances git-repository-id commit
|
||||||
|
channel-derivations-by-system)))
|
||||||
|
(let ((store-item
|
||||||
|
(channel-derivations-by-system->guix-store-item
|
||||||
|
store
|
||||||
|
channel-derivations-by-system)))
|
||||||
|
(if store-item
|
||||||
|
(begin
|
||||||
|
(extract-information-from conn store
|
||||||
|
guix-revision-id
|
||||||
|
commit store-item)
|
||||||
|
|
||||||
(with-time-logging
|
(if (defined? 'channel-news-for-commit
|
||||||
"acquiring advisory transaction lock: load-new-guix-revision-inserts"
|
(resolve-module '(guix channels)))
|
||||||
;; Wait until this is the only transaction inserting data, to avoid any
|
(with-time-logging "inserting channel news entries"
|
||||||
;; concurrency issues
|
(insert-channel-news-entries-for-guix-revision
|
||||||
(obtain-advisory-transaction-lock conn
|
conn
|
||||||
'load-new-guix-revision-inserts))
|
guix-revision-id
|
||||||
(let* ((existing-guix-revision-id
|
(channel-news-for-commit channel-for-commit commit)))
|
||||||
(git-repository-id-and-commit->revision-id conn
|
(begin
|
||||||
git-repository-id
|
(simple-format
|
||||||
commit))
|
#t "debug: importing channel news not supported\n")
|
||||||
(guix-revision-id
|
#t))
|
||||||
(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")
|
|
||||||
|
|
||||||
;; COMMIT so that the channel instances are saved to the database, then
|
(update-package-derivations-table conn
|
||||||
;; start a new transaction for the rest of the processing.
|
git-repository-id
|
||||||
(exec-query conn "COMMIT")
|
guix-revision-id
|
||||||
(exec-query conn "BEGIN")
|
commit))
|
||||||
|
(begin
|
||||||
(let ((store-item
|
(simple-format #t "Failed to generate store item for ~A\n"
|
||||||
(channel-derivations-by-system->guix-store-item
|
commit)
|
||||||
store
|
#f)))))
|
||||||
channel-derivations-by-system)))
|
|
||||||
(if store-item
|
|
||||||
(begin
|
|
||||||
(extract-information-from conn store
|
|
||||||
guix-revision-id
|
|
||||||
commit store-item)
|
|
||||||
|
|
||||||
(if (defined? 'channel-news-for-commit
|
|
||||||
(resolve-module '(guix channels)))
|
|
||||||
(with-time-logging "inserting channel news entries"
|
|
||||||
(insert-channel-news-entries-for-guix-revision
|
|
||||||
conn
|
|
||||||
guix-revision-id
|
|
||||||
(channel-news-for-commit channel-for-commit commit)))
|
|
||||||
(begin
|
|
||||||
(simple-format
|
|
||||||
#t "debug: importing channel news not supported\n")
|
|
||||||
#t))
|
|
||||||
|
|
||||||
(update-package-derivations-table conn
|
|
||||||
git-repository-id
|
|
||||||
guix-revision-id
|
|
||||||
commit))
|
|
||||||
(begin
|
|
||||||
(simple-format #t "Failed to generate store item for ~A\n"
|
|
||||||
commit)
|
|
||||||
#f))))))
|
|
||||||
|
|
||||||
(define (enqueue-load-new-guix-revision-job conn git-repository-id commit source)
|
(define (enqueue-load-new-guix-revision-job conn git-repository-id commit source)
|
||||||
(define query
|
(define query
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue