* src/cuirass/database.scm (db-update-build-status!): And "AND status != ?"
in SQL queries.
* tests/database.scm ("database")["db-update-build-status!"]: Add call
to 'db-update-build-status!'.
This is purely "defensive programming" since the default value for
'print-build-trace' is currently #t.
* src/cuirass/base.scm (with-store): Pass #:print-build-trace to
'set-build-options'.
* src/cuirass/database.scm (%sqlite-exec): Remove.
(sqlite-exec): Turn back into a procedure. Use 'sqlite-bind'. Add
'normalize' procedure and use it.
(db-add-specification, db-add-derivation, db-get-derivation)
(db-add-evaluation, db-add-build, db-update-build-status!)
(db-get-build, db-get-stamp, db-add-stamp): Use question marks in SQL
queries.
* src/cuirass/base.scm (build-packages)[register]: Make #:log
non-false.
* tests/database.scm (make-dummy-job): Add #:job-name, #:system,
#:nix-name, and #:eval-id. This is necessary because 'sqlite-bind'
would now translate #f to a real NULL (before it would translate to the
string "#f"...), and would thus report violations of the non-NULL
constraint.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Reported by Danny Milosavljevic.
* src/cuirass/http.scm (url-handler) <"jobsets"> Return the result of
'db-get-specifications' as-is, not just the car.
Works around <https://github.com/wingo/fibers/issues/19>.
The effect in practice would be that we'd usually not reach the
'close-pipe' call in 'evaluate', leaving zombie processes behind us,
never executing the continuation, and additionally spinning fast on a
sequence of epoll_wait/epoll_ctl calls.
* src/cuirass/base.scm <top level>: Monkey-patch (fibers internal).
We used to have 'build-derivations' write to the custom binary port
returned by 'build-event-output-port'. However, custom binary ports
constitute continuation barriers, thereby preventing fibers from being
suspended.
To make build log processing non-blocking, we therefore invert this
inversion of control and use a suspendable I/O procedure,
'read-line/non-blocking', when reading the build log.
* src/cuirass/base.scm (read-line/non-blocking, process-build-log)
(build-derivations&): New procedures.
(%newline, build-event-output-port): Remove.
(spawn-builds): Use 'build-derivations&' instead of 'build-derivations'
with 'build-event-output-port'.
This should placate 'guix-hydra-queued-builds', for instance, which
checks these values to choose between "Running" and "Scheduled".
* src/cuirass/http.scm (build->hydra-build): Provide the correct value
for #:finished and #:busy.
Fixes a bug whereby 'build-event-output-port' would sometimes read more
than COUNT from BV, which would usually result in a 'decoding-error'
exception from 'utf8->string'.
* src/cuirass/base.scm (build-event-output-port)[write!]: Use
'bytevector-range' to honor COUNT and OFFSET.
Previously these calls would effectively suspend execution of all the
fibers until they had completed.
* src/cuirass/base.scm (process-specs): Wrap 'fetch-repository' and
'compile' calls in 'non-blocking'.
* src/cuirass/logging.scm (call-with-time-logging): New procedure.
(with-time-logging): New macro.
* src/cuirass/http.scm (handle-builds-request): Use it.
* src/cuirass/base.scm (handle-build-event)[valid?]: New procedure.
Use it when handling 'build-started', 'build-succeeded', and
'build-failed' events.
* src/cuirass/database.scm (db-get-builds)[format-order-clause]: Add
'order' clauses.
* src/cuirass/http.scm (url-handler): Default to (order finish-time) for
/latestbuilds and (order submission-time) for /queue.
This works around a scalability issue in guix-daemon when passing a long
list of derivations to 'build-derivations'.
* src/cuirass/base.scm (spawn-builds): New procedure.
(restart-builds, build-packages): Use it.
* src/cuirass/database.scm (sqlite-exec): Use (ice-9 format).
(db-update-build-status!): Add #:log-file parameter and honor it.
* tests/database.scm ("database")["db-update-build-status!"]: Test it.
Fixes a regression introduced in
d7306a4f48 whereby 'register' would pass
the empty list as #:outputs to 'db-add-build'.
* src/cuirass/base.scm (build-packages)[register]: Always include
outputs.