2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2024-12-29 11:40:16 +01:00

database: Add ‘with-timing-check’ for operations on dependencies.

* src/cuirass/database.scm (db-reschedule-dependent-builds): Wrap
‘exec-query/bind’ in ‘with-timing-check’.
(db-mark-as-failed-if-dependencies-failed): Likewise.
(db-mark-failed-dependency-builds): Likewise.
This commit is contained in:
Ludovic Courtès 2024-10-05 12:02:22 +02:00
parent e53d596ca2
commit d894a914f6
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1151,8 +1151,11 @@ WHERE dep.source = " build))
dependencies.
Note: This is an expensive query but is usually rarely needed."
(let ((rescheduled (with-db-connection db
(exec-query/bind db "
(let ((rescheduled
(with-db-connection db
(with-timing-check (format #f "rescheduling dependents of build ~a"
(build-id build))
(exec-query/bind db "
UPDATE Builds SET status = " (build-status scheduled) "
FROM
-- Select the dependents of this build with exactly one failing
@ -1169,7 +1172,8 @@ FROM
ON dependencies.id = bd.target AND dependencies.status != 0
GROUP BY dependents.id HAVING count(dependencies.id) = 0)
AS relevantdependents
WHERE Builds.id = relevantdependents.id;"))))
WHERE Builds.id = relevantdependents.id;")
#:threshold 10))))
(log-info "rescheduled ~a dependent builds of build ~a (~a)"
rescheduled (build-id build) (build-derivation build))
rescheduled))
@ -1178,7 +1182,9 @@ WHERE Builds.id = relevantdependents.id;"))))
"Mark the build of DRV as 'failed-dependency' if it has one or more failed
dependencies."
(with-db-connection db
(unless (zero? (exec-query/bind db "
(with-timing-check (format #f "checking for failed dependencies of '~a'"
drv)
(unless (zero? (exec-query/bind db "
UPDATE Builds SET status = " (build-status failed-dependency) "
FROM
(SELECT count(Builds.id) AS total FROM Builds
@ -1187,7 +1193,8 @@ FROM
WHERE bd.source = source.id AND Builds.status > 0)
AS faileddependencies
WHERE Builds.derivation = " drv " AND faileddependencies.total > 0;"))
(log-info "marked build of ~a as 'failed-dependency'" drv))))
(log-info "marked build of ~a as 'failed-dependency'" drv))
#:threshold 10)))
(define (db-mark-failed-dependency-builds)
"Update the build status of the scheduled builds with failed dependencies to
@ -1198,7 +1205,9 @@ WHERE Builds.derivation = " drv " AND faileddependencies.total > 0;"))
;; dependents have been marked, doesn't scale well because it potentially
;; requires a large number of SQL queries.
(with-db-connection db
(let ((marked (exec-query/bind db "
(let ((marked
(with-timing-check "marking 'failed-dependency' builds"
(exec-query/bind db "
UPDATE Builds
SET status = " (build-status failed-dependency) ",
starttime = extract(epoch from now())::int,
@ -1207,7 +1216,7 @@ FROM (SELECT Builds.id, count(dep.id) as deps FROM Builds
LEFT JOIN BuildDependencies as bd ON bd.source = Builds.id
INNER JOIN Builds AS dep ON bd.target = dep.id AND dep.status > 0
WHERE Builds.status = " (build-status scheduled)
" GROUP BY Builds.id) AS deps WHERE deps.id = Builds.id")))
" GROUP BY Builds.id) AS deps WHERE deps.id = Builds.id"))))
(unless (zero? marked)
(log-info "marked ~a builds as 'failed-dependency'"
marked)))))