Handle deleting from blocked_builds when builds are scheduled
As scheduling a build might unblock others.
This commit is contained in:
parent
b9305d81a4
commit
ed114265cd
2 changed files with 30 additions and 3 deletions
|
|
@ -27,7 +27,7 @@
|
|||
#:use-module (guix-data-service model system)
|
||||
#:use-module (guix-data-service model guix-revision)
|
||||
#:use-module (guix-data-service model build)
|
||||
#:export (handle-populating-blocked-builds-for-scheduled-builds
|
||||
#:export (handle-blocked-builds-entries-for-scheduled-builds
|
||||
handle-populating-blocked-builds-for-build-failures
|
||||
handle-removing-blocking-build-entries-for-successful-builds
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ ON CONFLICT DO NOTHING")
|
|||
|
||||
#t)
|
||||
|
||||
(define (handle-populating-blocked-builds-for-scheduled-builds conn build-ids)
|
||||
(define (handle-blocked-builds-entries-for-scheduled-builds conn build-ids)
|
||||
(define (get-build-details build-id)
|
||||
(define query
|
||||
"
|
||||
|
|
@ -188,6 +188,29 @@ WHERE id = $1")
|
|||
|
||||
(exec-query conn query (list (number->string build-id))))
|
||||
|
||||
(define delete-query
|
||||
(string-append
|
||||
"
|
||||
DELETE FROM blocked_builds
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM builds
|
||||
WHERE builds.id IN (" (string-join
|
||||
(map number->string build-ids)
|
||||
", ")
|
||||
")
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM latest_build_status
|
||||
WHERE latest_build_status.build_id = builds.id
|
||||
AND latest_build_status.status = 'scheduled'
|
||||
)
|
||||
AND blocked_builds.build_server_id = builds.build_server_id
|
||||
AND blocked_builds.blocking_derivation_output_details_set_id
|
||||
= builds.derivation_output_details_set_id
|
||||
)"))
|
||||
|
||||
;; Insert entries for each build if it's blocked
|
||||
(for-each
|
||||
(lambda (build-id)
|
||||
(match (get-build-details build-id)
|
||||
|
|
@ -207,6 +230,10 @@ WHERE id = $1")
|
|||
blocking-derivation-output-details-set-ids)))))))
|
||||
build-ids)
|
||||
|
||||
;; This build being scheduled might unblock other builds, so delete the
|
||||
;; associated entries
|
||||
(exec-query conn delete-query '())
|
||||
|
||||
#t)
|
||||
|
||||
(define (handle-populating-blocked-builds-for-build-failures conn build-ids)
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@
|
|||
build-ids)
|
||||
|
||||
(spawn-fiber-for-build-handler
|
||||
handle-populating-blocked-builds-for-scheduled-builds
|
||||
handle-blocked-builds-entries-for-scheduled-builds
|
||||
'("scheduled")
|
||||
items
|
||||
build-ids)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue