From a0a7d66b1dbcd17c880c3dcfa9929cf8daf8922c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 19 Feb 2022 09:54:39 +0000 Subject: Move logging cleanup tasks to after the transaction commits As I think some operations (like the database backup) can block the DROP SEQUENCE bit, so at least this approach means that the main transaction should commit and then the sequence is eventually dropped. --- guix-data-service/jobs/load-new-guix-revision.scm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 8a7e5aa..d8f49ca 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -303,7 +303,7 @@ WHERE job_id = $1") (exec-query conn (string-append - "DROP SEQUENCE " + "DROP SEQUENCE IF EXISTS " (log-part-sequence-name job-id)))) (define (vacuum-log-parts-table conn) @@ -1820,13 +1820,15 @@ SKIP LOCKED") (close-port logging-port) (combine-log-parts! logging-conn id) - (drop-log-parts-sequence logging-conn id) - (with-time-logging "vacuuming log parts" - (vacuum-log-parts-table logging-conn)) result)))))) result)) +(define (cleanup-logging id conn) + (drop-log-parts-sequence conn id) + (with-time-logging "vacuuming log parts" + (vacuum-log-parts-table conn))) + (prevent-inlining-for-tests setup-logging) (define (process-load-new-guix-revision-job id) @@ -1881,6 +1883,10 @@ SKIP LOCKED") (record-job-event conn id "success") (exec-query conn "COMMIT") + (with-time-logging + "cleanup logging" + (cleanup-logging id conn)) + (with-time-logging "vacuuming package derivations by guix revision range table" (vacuum-package-derivations-table conn)) @@ -1889,6 +1895,11 @@ SKIP LOCKED") (begin (exec-query conn "ROLLBACK") (record-job-event conn id "failure") + + (with-time-logging + "cleanup logging" + (cleanup-logging id conn)) + #f))) (() (exec-query conn "ROLLBACK") -- cgit v1.2.3