diff options
author | Christopher Baines <mail@cbaines.net> | 2024-12-05 20:56:23 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-12-09 10:53:06 +0000 |
commit | 5ed98343d78ea2f0e51e3d53a1d0807d01c5cab7 (patch) | |
tree | a02d73a97c75de12aee57d7b775709c037566375 /guix-data-service/model/git-branch.scm | |
parent | b128e9bd7a2cf896a396f5d29af05ca2a852c829 (diff) | |
download | data-service-5ed98343d78ea2f0e51e3d53a1d0807d01c5cab7.tar data-service-5ed98343d78ea2f0e51e3d53a1d0807d01c5cab7.tar.gz |
Rework loading revision data
These changes were motivated by switching to a mechanism of loading data that
isn't dependent on the big advisory lock that prevents more than one revision
from being processed at a time.
Since INSERT ... RETURNING id; is used, this can block if another transaction
inserts the same data, and then cause an error when that transaction
commits. The solution is to use ON CONFLICT DO NOTHING, but you have to handle
the case when the INSERT doesn't return an id since the other transaction has
inserted it.
This commit rewrites insert-missing-data-and-return-all-ids to do as described
above, as well as being more efficient in how existing data is detected and to
use more vectors. Other utilities for inserting data are added as well.
Diffstat (limited to 'guix-data-service/model/git-branch.scm')
-rw-r--r-- | guix-data-service/model/git-branch.scm | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/guix-data-service/model/git-branch.scm b/guix-data-service/model/git-branch.scm index a800e8f..c4b56c0 100644 --- a/guix-data-service/model/git-branch.scm +++ b/guix-data-service/model/git-branch.scm @@ -47,16 +47,12 @@ WHERE git_repository_id = $1 (define (insert-git-branch-entry conn git-repository-id name) - (match (exec-query - conn - " -INSERT INTO git_branches (git_repository_id, name) -VALUES ($1, $2) -RETURNING id" - (list (number->string git-repository-id) - name)) - (((id)) - (string->number id)))) + (insert-and-return-id + conn + "git_branches" + '(git_repository_id name) + (list git-repository-id + name))) (define (git-branches-for-commit conn commit) (define query |