aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-04-25 16:06:04 +0100
committerChristopher Baines <mail@cbaines.net>2023-04-25 16:06:04 +0100
commit040d782804dfa298a8d3e03c632e490e024aa255 (patch)
tree7fcea588e607e8c854326936165f1c9e0325c447
parente0f6f9ed4a9ba128657a379a855769f8bbf3abdb (diff)
downloadbuild-coordinator-040d782804dfa298a8d3e03c632e490e024aa255.tar
build-coordinator-040d782804dfa298a8d3e03c632e490e024aa255.tar.gz
Log long database operations
There's the delay logger that applies to all operations, but it would be helpful to see any long read or write as well.
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm20
1 files changed, 18 insertions, 2 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index aa4394d..974f538 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -191,7 +191,15 @@ CREATE TABLE IF NOT EXISTS mem.build_allocation_plan (
(format
(current-error-port)
"warning: database write delayed by ~1,2f seconds~%"
- seconds-delayed))))))
+ seconds-delayed))))
+ #:duration-logger
+ (lambda (duration proc)
+ (when (> duration 30)
+ (format
+ (current-error-port)
+ "warning: database write took ~1,2f seconds (~a)~%"
+ duration
+ proc)))))
;; Make sure the worker thread has initialised, and created the in memory
;; tables
@@ -244,7 +252,15 @@ CREATE TABLE IF NOT EXISTS mem.build_allocation_plan (
(format
(current-error-port)
"warning: database read delayed by ~1,2f seconds~%"
- seconds-delayed))))))
+ seconds-delayed))))
+ #:duration-logger
+ (lambda (duration proc)
+ (when (> duration 30)
+ (format
+ (current-error-port)
+ "warning: database read took ~1,2f seconds (~a)~%"
+ duration
+ proc)))))
datastore))