feat: download lifecycle — stalled and failed downloads are given up and searched again; imported ones seed, then go (M502 #5523)
release / govulncheck (push) Successful in 17s
release / web (push) Failing after 17s
release / go (push) Successful in 1m11s
release / integration (push) Successful in 4m50s
release / android (push) Successful in 4m54s
release / Build signed APK (releases and dev) (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 17s
release / web (push) Failing after 17s
release / go (push) Successful in 1m11s
release / integration (push) Successful in 4m50s
release / android (push) Successful in 4m54s
release / Build signed APK (releases and dev) (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
Ported from Fabled Librarian's System 104. A new lifecycle poller, every ten minutes: - a download the client fails is given up at once; - one nobody shares, or still fetching its file list, past the stall setting (6 h) is asked for again three times, then given up; - giving up removes the download with its files, holds the release back for a week (release_blocks.expires_at), ends the grab and searches the album again, with no limit per album; - a running download the client stops listing for half an hour ends and is searched again, not held back; an empty list is not taken as gone; - an imported download seeds to ratio 2.0 or 14 days, then is removed; - a download the client would not remove is asked again every pass. Every condition and act is one open row per (client, download, condition) in download_interventions. Activity shows what is wrong with a download and how often it was retried, why one ended, its seeding, and a banner for a client that does not answer. A running download can be given up by hand (set aside for good). The seed ratio, seed days and stall hours are on the search settings card. The download client lookup moves to acquire.DownloadClientFor, shared by the importer and the lifecycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,9 @@ UPDATE acquisition_settings
|
||||
search_interval_hours = sqlc.arg(search_interval_hours),
|
||||
allowed_qualities = sqlc.arg(allowed_qualities),
|
||||
import_root = sqlc.arg(import_root),
|
||||
seed_ratio = sqlc.arg(seed_ratio),
|
||||
seed_days = sqlc.arg(seed_days),
|
||||
stall_hours = sqlc.arg(stall_hours),
|
||||
updated_at = now()
|
||||
WHERE id = true
|
||||
RETURNING *;
|
||||
@@ -109,14 +112,23 @@ UPDATE grabs
|
||||
WHERE id = sqlc.arg(id) AND ended_at IS NULL;
|
||||
|
||||
-- name: ListReleaseBlocks :many
|
||||
SELECT * FROM release_blocks ORDER BY blocked_at DESC;
|
||||
-- Every release set aside and still held back: a stalled one lifts by itself
|
||||
-- at expires_at (#5523).
|
||||
SELECT * FROM release_blocks
|
||||
WHERE expires_at IS NULL OR expires_at > now()
|
||||
ORDER BY blocked_at DESC;
|
||||
|
||||
-- name: BlockRelease :exec
|
||||
INSERT INTO release_blocks (info_hash, name, reason, detail, want_id, blocked_by)
|
||||
-- A release set aside. expires_at NULL is for good. A block for good is never
|
||||
-- shortened by a timed one: only a timed block, or another for good, is
|
||||
-- replaced.
|
||||
INSERT INTO release_blocks (info_hash, name, reason, detail, want_id, blocked_by, expires_at)
|
||||
VALUES (sqlc.arg(info_hash), sqlc.arg(name), sqlc.arg(reason), sqlc.arg(detail),
|
||||
sqlc.narg(want_id), sqlc.narg(blocked_by))
|
||||
sqlc.narg(want_id), sqlc.narg(blocked_by), sqlc.narg(expires_at))
|
||||
ON CONFLICT (info_hash) DO UPDATE
|
||||
SET reason = EXCLUDED.reason, detail = EXCLUDED.detail, blocked_at = now();
|
||||
SET reason = EXCLUDED.reason, detail = EXCLUDED.detail, blocked_at = now(),
|
||||
expires_at = EXCLUDED.expires_at, blocked_by = EXCLUDED.blocked_by
|
||||
WHERE release_blocks.expires_at IS NOT NULL OR EXCLUDED.expires_at IS NULL;
|
||||
|
||||
-- name: UnblockRelease :execrows
|
||||
DELETE FROM release_blocks WHERE info_hash = $1;
|
||||
|
||||
Reference in New Issue
Block a user