From 040d782804dfa298a8d3e03c632e490e024aa255 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 25 Apr 2023 16:06:04 +0100 Subject: 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. --- guix-build-coordinator/datastore/sqlite.scm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'guix-build-coordinator/datastore') 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)) -- cgit v1.2.3