aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/jobs/load-new-guix-revision.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-07-12 19:54:25 +0100
committerChristopher Baines <mail@cbaines.net>2019-07-12 19:57:13 +0100
commita6bd46b829070fca8843bc0155e5bf2b71d422dd (patch)
tree66cf242c4f1c0a53468870f17dfa43cc963223fa /guix-data-service/jobs/load-new-guix-revision.scm
parent05c828796514b7bcd8a613da8ab1d6a5402931fa (diff)
downloaddata-service-a6bd46b829070fca8843bc0155e5bf2b71d422dd.tar
data-service-a6bd46b829070fca8843bc0155e5bf2b71d422dd.tar.gz
Obtain a lock when inserting the data for a new revision
This is working towards running the jobs in parallel. Each job looks at the records in the database, and adds missing ones. If other jobs, running in different transactions insert the same missing records at the same time, this could cause an error. Therefore, to just avoid this problem, lock before inserting the data. This will allow the jobs to be processed in parallel, and it shouldn't have too much of an effect on performance, as the slow bit is outside of the transaction.
Diffstat (limited to 'guix-data-service/jobs/load-new-guix-revision.scm')
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm5
1 files changed, 5 insertions, 0 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index 401a2c7..a69b690 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -553,6 +553,11 @@
(lambda ()
(all-inferior-package-derivations store inf packages)))))
+ ;; Wait until this is the only transaction inserting data, to
+ ;; avoid any concurrency issues
+ (obtain-advisory-transaction-lock conn
+ 'load-new-guix-revision-inserts)
+
(let* ((package-derivation-ids
(packages-and-inferior-data->package-derivation-ids
conn inf packages inferior-data-4-tuples))