Delete unreferenced derivations in batches
To avoid a long blocking query.
This commit is contained in:
parent
1c75394187
commit
7495085f63
1 changed files with 18 additions and 8 deletions
|
|
@ -425,15 +425,25 @@ WHERE build_server_id = $1
|
||||||
build-server-ids)))
|
build-server-ids)))
|
||||||
|
|
||||||
(define (delete-unreferenced-derivations-source-files conn)
|
(define (delete-unreferenced-derivations-source-files conn)
|
||||||
(exec-query
|
(define (delete-batch)
|
||||||
conn
|
(exec-query
|
||||||
"
|
conn
|
||||||
|
"
|
||||||
DELETE FROM derivation_source_files
|
DELETE FROM derivation_source_files
|
||||||
WHERE NOT EXISTS (
|
WHERE id IN (
|
||||||
SELECT 1
|
SELECT id
|
||||||
FROM derivation_sources
|
FROM derivation_source_files
|
||||||
WHERE derivation_source_file_id = derivation_source_files.id
|
WHERE NOT EXISTS (
|
||||||
)"))
|
SELECT 1
|
||||||
|
FROM derivation_sources
|
||||||
|
WHERE derivation_source_file_id = derivation_source_files.id
|
||||||
|
)
|
||||||
|
LIMIT 100
|
||||||
|
)
|
||||||
|
RETURNING id"))
|
||||||
|
|
||||||
|
(while (not (null? (delete-batch)))
|
||||||
|
#t))
|
||||||
|
|
||||||
(define (maybe-delete-derivation conn id)
|
(define (maybe-delete-derivation conn id)
|
||||||
(match (map
|
(match (map
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue