From b43f0a967d68fb1c5ce1f2c82727c78e8b954b6c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 22 Apr 2023 17:14:07 +0100 Subject: Don't block writes for as long when attempting checkpoints --- guix-build-coordinator/datastore/sqlite.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'guix-build-coordinator/datastore') diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index 31f2f4d..a93b377 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -259,9 +259,10 @@ metrics-registry checkpoint-duration-metric-name (lambda () - (when (> (wal-size) extreme-wal-size-threshold) - ;; Since the WAL is really getting too big, wait for much longer - (sqlite-exec db "PRAGMA busy_timeout = 300000;")) + (if (> (wal-size) extreme-wal-size-threshold) + ;; Since the WAL is really getting too big, wait for much longer + (sqlite-exec db "PRAGMA busy_timeout = 300000;") + (sqlite-exec db "PRAGMA busy_timeout = 100;")) (let* ((statement (sqlite-prepare @@ -326,9 +327,11 @@ PRAGMA optimize;") (retry-count 0)) (if result #t - (if (< retry-count 10) - (loop (datastore-optimize datastore) - (+ 1 retry-count)) + (if (< retry-count 300) + (begin + (sleep 0.1) + (loop (datastore-optimize datastore) + (+ 1 retry-count))) (error "unable to perform WAL checkpoint")))))) #:unwind? #t))) #:parallel? #t)) -- cgit v1.2.3