Delete unreferenced derivations in batches
To avoid a long blocking query.
This commit is contained in:
parent
1c75394187
commit
7495085f63
|
@ -425,15 +425,25 @@ WHERE build_server_id = $1
|
|||
build-server-ids)))
|
||||
|
||||
(define (delete-unreferenced-derivations-source-files conn)
|
||||
(exec-query
|
||||
conn
|
||||
"
|
||||
(define (delete-batch)
|
||||
(exec-query
|
||||
conn
|
||||
"
|
||||
DELETE FROM derivation_source_files
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM derivation_sources
|
||||
WHERE derivation_source_file_id = derivation_source_files.id
|
||||
)"))
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM derivation_source_files
|
||||
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)
|
||||
(match (map
|
||||
|
|
Loading…
Reference in New Issue