From ff116d5e6437ffb916aa4bc5d1458a142297a900 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 7 May 2022 09:55:13 +0100 Subject: [PATCH] Clear out cached store connections in the load revision inferior These cached store connections have caches associated with them, that take up lots of memory, leading to the inferior crashing. This change seems to help. --- .../jobs/load-new-guix-revision.scm | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index fbced1d..e499a8b 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -731,17 +731,30 @@ WHERE job_id = $1") (round (/ (assoc-ref (gc-stats) 'heap-size) (expt 2. 20)))) - (with-time-logging - (simple-format #f "getting derivations for ~A" system-target-pair) - (catch - 'match-error - (lambda () - (inferior-eval '(invalidate-derivation-caches!) inf)) - (lambda (key . args) - (simple-format - (current-error-port) - "warning: ignoring match-error from calling inferior invalidate-derivation-caches!\n"))) - (inferior-eval-with-store inf store (proc packages (list system-target-pair))))) + + (format (current-error-port) + "inferior heap size: ~a MiB~%" + (round + (/ (inferior-eval '(assoc-ref (gc-stats) 'heap-size) inf) + (expt 2. 20)))) + + (let ((derivations + (with-time-logging + (simple-format #f "getting derivations for ~A" system-target-pair) + (catch + 'match-error + (lambda () + (inferior-eval '(invalidate-derivation-caches!) inf)) + (lambda (key . args) + (simple-format + (current-error-port) + "warning: ignoring match-error from calling inferior invalidate-derivation-caches!\n"))) + (inferior-eval-with-store inf store (proc packages (list system-target-pair)))))) + + ;; Clean the cached store connections, as there are caches associated + ;; with these that take up lots of memory + (inferior-eval '(when (defined? '%store-table) (hash-clear! %store-table)) inf) + derivations)) (append supported-system-pairs supported-system-cross-build-pairs)))