From 38b36570132f8463cc763256aeab7613656278e6 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 28 Nov 2022 10:26:46 +0000 Subject: [PATCH] Use advisory locks to avoid deadlocks during data deletion In the case where multiple data deleting processes end up running at the same time. --- guix-data-service/data-deletion.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guix-data-service/data-deletion.scm b/guix-data-service/data-deletion.scm index e4762c9..6794bea 100644 --- a/guix-data-service/data-deletion.scm +++ b/guix-data-service/data-deletion.scm @@ -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 "