Use advisory locks to avoid deadlocks during data deletion

In the case where multiple data deleting processes end up running at the same
time.
This commit is contained in:
Christopher Baines 2022-11-28 10:26:46 +00:00
parent ad93a780d3
commit 38b3657013

View file

@ -206,6 +206,10 @@ WHERE id IN (
(with-postgresql-transaction
conn
(lambda (conn)
(obtain-advisory-transaction-lock
conn
'delete-revisions-from-branch)
(delete-from-git-commits conn)
(delete-jobs conn)
@ -538,6 +542,10 @@ WHERE NOT EXISTS (
(with-postgresql-transaction
conn
(lambda (conn)
(obtain-advisory-transaction-lock
conn
'delete-unreferenced-derivations)
(exec-query
conn
"