diff options
author | Christopher Baines <mail@cbaines.net> | 2021-12-20 10:01:36 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-12-20 10:01:36 +0000 |
commit | 87827e57be4b237054a1b17ea6e5bbbbef0b4362 (patch) | |
tree | 1df3e8af4932560f37734b6fe2bd8e603d6d3439 /guix-build-coordinator/datastore | |
parent | 2cb8c972e8a2737a1878ad79c0d24ac01d1fe036 (diff) | |
download | build-coordinator-87827e57be4b237054a1b17ea6e5bbbbef0b4362.tar build-coordinator-87827e57be4b237054a1b17ea6e5bbbbef0b4362.tar.gz |
Reduce the time in the transaction when replacing the allocation plan
Diffstat (limited to 'guix-build-coordinator/datastore')
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index 8164e0b..3ed79e8 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -2467,24 +2467,30 @@ GROUP BY agent_id" db "DELETE FROM build_allocation_plan")) + (define insert-sql + (call-with-worker-thread + (slot-ref datastore 'worker-reader-thread-channel) + (lambda (db) + (string-append + " +INSERT INTO build_allocation_plan (build_id, agent_id, ordering) VALUES " + (string-join + (map (match-lambda + ((build-uuid agent-id ordering) + (simple-format + #f + "('~A', '~A', ~A)" + (db-find-build-id db build-uuid) + agent-id + ordering))) + planned-builds) + ", ") + ";")))) + (define (insert-new-plan db planned-builds) (sqlite-exec db - (string-append - " -INSERT INTO build_allocation_plan (build_id, agent_id, ordering) VALUES " - (string-join - (map (match-lambda - ((build-uuid agent-id ordering) - (simple-format - #f - "('~A', '~A', ~A)" - (db-find-build-id db build-uuid) - agent-id - ordering))) - planned-builds) - ", ") - ";"))) + insert-sql)) (datastore-call-with-transaction datastore |