Move the delete-unreferenced-derivations advisory lock

To better prevent two processes running at the same time.
This commit is contained in:
Christopher Baines 2023-02-27 22:48:54 +00:00
parent 8c2f97eef8
commit 1bce38a69d

View file

@ -561,10 +561,6 @@ WHERE NOT EXISTS (
(with-postgresql-transaction
conn
(lambda (conn)
(obtain-advisory-transaction-lock
conn
'delete-unreferenced-derivations)
(exec-query
conn
"
@ -585,6 +581,10 @@ SET CONSTRAINTS derivations_by_output_details_set_derivation_id_fkey DEFERRED")
(lambda ()
(with-thread-postgresql-connection
(lambda (conn)
(obtain-advisory-transaction-lock
conn
'delete-unreferenced-derivations)
(let loop ((total-deleted 0))
(let ((batch-deleted-count (delete-batch conn)))
(if (eq? 0 batch-deleted-count)