aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-02-19 09:54:39 +0000
committerChristopher Baines <mail@cbaines.net>2022-02-19 09:54:39 +0000
commita0a7d66b1dbcd17c880c3dcfa9929cf8daf8922c (patch)
tree777c0a6c1e9ae7eb2b195764e3cc93c4d279a16e
parent17167ef3e445cdf880f9d9862e7bfc07552bd86f (diff)
downloaddata-service-a0a7d66b1dbcd17c880c3dcfa9929cf8daf8922c.tar
data-service-a0a7d66b1dbcd17c880c3dcfa9929cf8daf8922c.tar.gz
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.
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm19
1 files 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)
@@ -1882,6 +1884,10 @@ SKIP LOCKED")
(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")