database: ensure update-or-insert is run within a transaction
authorCaleb Ristvedt <caleb.ristvedt@cune.org>
Tue, 2 Jun 2020 02:43:14 +0000 (21:43 -0500)
committerCaleb Ristvedt <caleb.ristvedt@cune.org>
Thu, 11 Jun 2020 02:54:35 +0000 (21:54 -0500)
commit37545de4a3bf59611c184b31506fe9a16abe4c8b
tree2f2e008a7634262c59ac4be3ee59731fa0c6a754
parent5d6e2255286e591def122ec2f4a3cbda497fea21
database: ensure update-or-insert is run within a transaction

update-or-insert can break if an insert occurs between when it decides whether
to update or insert and when it actually performs that operation.  Putting the
check and the update/insert operation in the same transaction ensures that the
update/insert will only succeed if no other write has occurred in the middle.

* guix/store/database.scm (call-with-savepoint): new procedure.
  (update-or-insert): use call-with-savepoint to ensure the read and the
  insert/update occur within the same transaction.
.dir-locals.el
guix/store/database.scm