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.
This commit is contained in:
Christopher Baines 2022-02-19 09:54:39 +00:00
parent 17167ef3e4
commit a0a7d66b1d

View file

@ -303,7 +303,7 @@ WHERE job_id = $1")
(exec-query (exec-query
conn conn
(string-append (string-append
"DROP SEQUENCE " "DROP SEQUENCE IF EXISTS "
(log-part-sequence-name job-id)))) (log-part-sequence-name job-id))))
(define (vacuum-log-parts-table conn) (define (vacuum-log-parts-table conn)
@ -1820,13 +1820,15 @@ SKIP LOCKED")
(close-port logging-port) (close-port logging-port)
(combine-log-parts! logging-conn id) (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))))))
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) (prevent-inlining-for-tests setup-logging)
(define (process-load-new-guix-revision-job id) (define (process-load-new-guix-revision-job id)
@ -1881,6 +1883,10 @@ SKIP LOCKED")
(record-job-event conn id "success") (record-job-event conn id "success")
(exec-query conn "COMMIT") (exec-query conn "COMMIT")
(with-time-logging
"cleanup logging"
(cleanup-logging id conn))
(with-time-logging (with-time-logging
"vacuuming package derivations by guix revision range table" "vacuuming package derivations by guix revision range table"
(vacuum-package-derivations-table conn)) (vacuum-package-derivations-table conn))
@ -1889,6 +1895,11 @@ SKIP LOCKED")
(begin (begin
(exec-query conn "ROLLBACK") (exec-query conn "ROLLBACK")
(record-job-event conn id "failure") (record-job-event conn id "failure")
(with-time-logging
"cleanup logging"
(cleanup-logging id conn))
#f))) #f)))
(() (()
(exec-query conn "ROLLBACK") (exec-query conn "ROLLBACK")