Delete derivations in parallel
In an attempt to make this faster.
This commit is contained in:
parent
16600b1a43
commit
54654417a3
1 changed files with 19 additions and 15 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
(define-module (guix-data-service data-deletion)
|
(define-module (guix-data-service data-deletion)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
|
#:use-module (ice-9 threads)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
#:use-module (guix-data-service utils)
|
#:use-module (guix-data-service utils)
|
||||||
#:use-module (guix-data-service database)
|
#:use-module (guix-data-service database)
|
||||||
|
|
@ -432,8 +433,10 @@ WHERE NOT EXISTS (
|
||||||
derivations-count)
|
derivations-count)
|
||||||
(let ((deleted-count
|
(let ((deleted-count
|
||||||
(fold
|
(fold
|
||||||
(lambda (id result)
|
(lambda (count result)
|
||||||
(+ result
|
(+ result count))
|
||||||
|
0
|
||||||
|
(par-map (lambda (derivation-id)
|
||||||
(with-postgresql-transaction/through-channel
|
(with-postgresql-transaction/through-channel
|
||||||
conn-channel
|
conn-channel
|
||||||
(lambda (conn)
|
(lambda (conn)
|
||||||
|
|
@ -442,9 +445,8 @@ WHERE NOT EXISTS (
|
||||||
"
|
"
|
||||||
SET CONSTRAINTS derivations_by_output_details_set_derivation_id_fkey DEFERRED")
|
SET CONSTRAINTS derivations_by_output_details_set_derivation_id_fkey DEFERRED")
|
||||||
|
|
||||||
(maybe-delete-derivation conn id)))))
|
(maybe-delete-derivation conn derivation-id))))
|
||||||
0
|
derivations))))
|
||||||
derivations)))
|
|
||||||
(simple-format (current-error-port)
|
(simple-format (current-error-port)
|
||||||
"Deleted ~A derivations\n"
|
"Deleted ~A derivations\n"
|
||||||
deleted-count)
|
deleted-count)
|
||||||
|
|
@ -453,8 +455,10 @@ SET CONSTRAINTS derivations_by_output_details_set_derivation_id_fkey DEFERRED")
|
||||||
(let loop ((total-deleted 0))
|
(let loop ((total-deleted 0))
|
||||||
(let ((batch-deleted-count (delete-batch conn)))
|
(let ((batch-deleted-count (delete-batch conn)))
|
||||||
(if (eq? 0 batch-deleted-count)
|
(if (eq? 0 batch-deleted-count)
|
||||||
|
(begin
|
||||||
|
(close-postgresql-connection-channel conn-channel)
|
||||||
(simple-format
|
(simple-format
|
||||||
(current-output-port)
|
(current-output-port)
|
||||||
"Finished deleting derivations, deleted ~A in total\n"
|
"Finished deleting derivations, deleted ~A in total\n"
|
||||||
total-deleted)
|
total-deleted))
|
||||||
(loop (+ total-deleted batch-deleted-count))))))))
|
(loop (+ total-deleted batch-deleted-count))))))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue