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:
parent
e53d596ca2
commit
d894a914f6
1 changed files with 16 additions and 7 deletions
|
@ -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)))))
|
||||
|
|
Loading…
Reference in a new issue