Set thread names

To help with debugging
This commit is contained in:
Christopher Baines 2023-07-09 19:27:11 +01:00
parent 75ef4cffd3
commit 2971322b27
2 changed files with 19 additions and 0 deletions

View file

@ -36,6 +36,8 @@
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix derivations) #:use-module (guix derivations)
#:use-module (guix build utils) #:use-module (guix build utils)
#:use-module ((guix build syscalls)
#:select (set-thread-name))
#:use-module (guix-data-service config) #:use-module (guix-data-service config)
#:use-module (guix-data-service database) #:use-module (guix-data-service database)
#:use-module (guix-data-service utils) #:use-module (guix-data-service utils)
@ -170,6 +172,11 @@ VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, $2)")
(setvbuf port-to-write-to 'line) (setvbuf port-to-write-to 'line)
(call-with-new-thread (call-with-new-thread
(lambda () (lambda ()
(catch 'system-error
(lambda ()
(set-thread-name "inferior logging"))
(const #t))
(with-postgresql-connection (with-postgresql-connection
(simple-format #f "~A inferior error logging" job-id) (simple-format #f "~A inferior error logging" job-id)
(lambda (logging-conn) (lambda (logging-conn)

View file

@ -24,6 +24,8 @@
#:use-module (fibers channels) #:use-module (fibers channels)
#:use-module (guix substitutes) #:use-module (guix substitutes)
#:use-module (guix narinfo) #:use-module (guix narinfo)
#:use-module ((guix build syscalls)
#:select (set-thread-name))
#:use-module (guix-data-service utils) #:use-module (guix-data-service utils)
#:use-module (guix-data-service database) #:use-module (guix-data-service database)
#:use-module (guix-data-service model build) #:use-module (guix-data-service model build)
@ -155,6 +157,11 @@
(call-with-new-thread (call-with-new-thread
(lambda () (lambda ()
(catch 'system-error
(lambda ()
(set-thread-name "request substitute query"))
(const #t))
(while #t (while #t
(with-exception-handler (with-exception-handler
(lambda (exn) (lambda (exn)
@ -196,6 +203,11 @@
(call-with-new-thread (call-with-new-thread
(lambda () (lambda ()
(catch 'system-error
(lambda ()
(set-thread-name "bulk substitute query"))
(const #t))
(while #t (while #t
(with-exception-handler (with-exception-handler
(lambda (exn) (lambda (exn)