diff options
author | Christopher Baines <mail@cbaines.net> | 2021-11-20 21:53:30 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-11-20 21:53:30 +0000 |
commit | d369fd7e3485d0849077e5f2f898f042e4aceca0 (patch) | |
tree | b5a8a96f271a671e0849e6f2eb41e58c50f9d090 /guix-build-coordinator/datastore | |
parent | c9c7c97bbfb49cb5749e2e9e5075a8edbb3f82b6 (diff) | |
download | build-coordinator-d369fd7e3485d0849077e5f2f898f042e4aceca0.tar build-coordinator-d369fd7e3485d0849077e5f2f898f042e4aceca0.tar.gz |
Improve delay logging in datastore-call-with-transaction
Make sure to log the delay in the calling thread.
Diffstat (limited to 'guix-build-coordinator/datastore')
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index a09bde7..55f3215 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -397,36 +397,40 @@ PRAGMA optimize;"))))) (sqlite-exec db "COMMIT TRANSACTION;") (apply values vals)))))))) - (call-with-worker-thread - (slot-ref datastore (if readonly? - 'worker-reader-thread-channel - 'worker-writer-thread-channel)) - (lambda (db) - (let ((start-time (get-internal-real-time))) - (call-with-values - (lambda () - (if duration-metric-name - (call-with-time-tracking - datastore - duration-metric-name + (match (call-with-worker-thread + (slot-ref datastore (if readonly? + 'worker-reader-thread-channel + 'worker-writer-thread-channel)) + (lambda (db) + (let ((start-time (get-internal-real-time))) + (call-with-values (lambda () - (run-proc-within-transaction db))) - (run-proc-within-transaction db))) - (lambda vals - (let ((duration-seconds - (/ (- (get-internal-real-time) start-time) - internal-time-units-per-second))) - (when (and (not readonly?) - (> duration-seconds 2)) - (display - (format - #f - "warning: ~a:\n took ~4f seconds in transaction\n" - proc - duration-seconds) - (current-error-port)))) - - (apply values vals))))))) + (if duration-metric-name + (call-with-time-tracking + datastore + duration-metric-name + (lambda () + (run-proc-within-transaction db))) + (run-proc-within-transaction db))) + (lambda vals + (let ((duration-seconds + (/ (- (get-internal-real-time) start-time) + internal-time-units-per-second))) + (when (and (not readonly?) + (> duration-seconds 2)) + (display + (format + #f + "warning: ~a:\n took ~4f seconds in transaction\n" + proc + duration-seconds) + (current-error-port))) + + (cons duration-seconds vals))))))) + ((duration vals ...) + (log-delay proc duration) + + (apply values vals)))) (define-method (datastore-find-agent (datastore <sqlite-datastore>) |