fix: a release its download client will not let Minstrel follow is held back, not taken every pass (#6176)
release / govulncheck (push) Successful in 16s
release / web (push) Successful in 1m21s
release / go (push) Successful in 1m34s
release / integration (push) Successful in 5m5s
release / android (push) Successful in 5m7s
release / Build signed APK (releases and dev) (push) Successful in 5m14s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 22s
release / Verify release artifacts (tag releases only) (push) Skipped

The Black Keys' Ohio Players was grabbed 40 times in a day. FabledExchange
already held the torrent under another category from before Minstrel took
the downloads over: the add answered "duplicate", which counted as added,
and Exchange's listing, filtered to Minstrel's category, never showed it.
Half an hour later the grab ended gone, and the next pass took it again.

- A duplicate add that the client does not list for Minstrel is not a
  grab: the release is held back for a day with the client's own reason
  (already downloading X (category)), and the search moves on. Forced,
  it is refused with that reason.
- A release that ends gone a second time within a week is held back for
  a day, whatever the cause.
- release_blocks gains the reason 'gone' (migration 0098), shown as
  "Held back: its download client lost track of it".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 11:31:57 -04:00
co-authored by Claude Opus 5.5
parent cb1f619a21
commit 484a81f779
11 changed files with 186 additions and 3 deletions
+19
View File
@@ -11,6 +11,25 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const countGoneGrabs = `-- name: CountGoneGrabs :one
SELECT count(*) FROM grabs
WHERE info_hash = $1 AND end_reason = 'gone' AND ended_at > $2
`
type CountGoneGrabsParams struct {
InfoHash string
Since pgtype.Timestamptz
}
// How many of a release's grabs ended gone since a time: a release that keeps
// leaving its client is held back rather than taken on every pass (#6176).
func (q *Queries) CountGoneGrabs(ctx context.Context, arg CountGoneGrabsParams) (int64, error) {
row := q.db.QueryRow(ctx, countGoneGrabs, arg.InfoHash, arg.Since)
var count int64
err := row.Scan(&count)
return count, err
}
const countRemediation = `-- name: CountRemediation :one
UPDATE download_interventions
SET remediations = remediations + 1,
@@ -0,0 +1,4 @@
DELETE FROM release_blocks WHERE reason = 'gone';
ALTER TABLE release_blocks DROP CONSTRAINT release_blocks_reason_check;
ALTER TABLE release_blocks ADD CONSTRAINT release_blocks_reason_check
CHECK (reason IN ('operator', 'files', 'import', 'stalled'));
@@ -0,0 +1,6 @@
-- #6176: gone, a release its download client would not let Minstrel follow:
-- held outside Minstrel's category, or leaving the client twice. Held back
-- until expires_at, as stalled is.
ALTER TABLE release_blocks DROP CONSTRAINT release_blocks_reason_check;
ALTER TABLE release_blocks ADD CONSTRAINT release_blocks_reason_check
CHECK (reason IN ('operator', 'files', 'import', 'stalled', 'gone'));
+6
View File
@@ -77,6 +77,12 @@ UPDATE grabs
WHERE id = sqlc.arg(id) AND ended_at IS NULL AND import_state = ANY(sqlc.arg(states)::text[])
RETURNING *;
-- name: CountGoneGrabs :one
-- How many of a release's grabs ended gone since a time: a release that keeps
-- leaving its client is held back rather than taken on every pass (#6176).
SELECT count(*) FROM grabs
WHERE info_hash = sqlc.arg(info_hash) AND end_reason = 'gone' AND ended_at > sqlc.arg(since);
-- name: ListSeedingGrabs :many
-- Imported downloads still sharing, oldest import first.
SELECT id, client, info_hash, name, imported_at FROM grabs