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.
This commit is contained in:
Christopher Baines 2019-07-12 19:54:25 +01:00
parent 05c8287965
commit a6bd46b829

View file

@ -553,6 +553,11 @@
(lambda () (lambda ()
(all-inferior-package-derivations store inf packages))))) (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 (let* ((package-derivation-ids
(packages-and-inferior-data->package-derivation-ids (packages-and-inferior-data->package-derivation-ids
conn inf packages inferior-data-4-tuples)) conn inf packages inferior-data-4-tuples))