The settler marks a settled release's candidates ready (and unreadable when it had no readable name). Claims took the candidates by joining releases from random points of the queue; in its newer half nothing had settled, so a slice scanned to the end (0.3 s each, 20 slices and 5 tiers a claim) and the prober stood still: 2.4M waiting, 0 probed a minute. Now an index over the claimable rows only, the slices drawn within them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
|
|
/**
|
|
* Candidates the prober may claim (Prober.claim): `ready` once their release
|
|
* settled (the settler sets it), `unreadable` when that release had no
|
|
* readable name then. The claims joined releases for both and started at
|
|
* random points of the queue; in its newer half nothing had settled, so a
|
|
* slice scanned to the end (0.3 s a slice, 20 slices, 5 tiers: the prober
|
|
* stood still for minutes per claim; LOG.md 2026-10-12 (20)). With an index
|
|
* over the claimable rows only.
|
|
*/
|
|
export default class extends BaseSchema {
|
|
static disableTransactions = true
|
|
|
|
async up() {
|
|
this.schema.raw(`ALTER TABLE probe_candidates ADD COLUMN IF NOT EXISTS ready boolean NOT NULL DEFAULT false`)
|
|
this.schema.raw(`ALTER TABLE probe_candidates ADD COLUMN IF NOT EXISTS unreadable boolean NOT NULL DEFAULT false`)
|
|
this.schema.raw(
|
|
`UPDATE probe_candidates pc SET ready = true, unreadable = NOT r.readable FROM releases r
|
|
WHERE r.id = pc.release_id AND r.settled_at IS NOT NULL AND NOT pc.ready`
|
|
)
|
|
this.schema.raw(`CREATE INDEX CONCURRENTLY IF NOT EXISTS probe_candidates_ready_idx ON probe_candidates (kind, unreadable, id) WHERE status = 'waiting' AND ready`)
|
|
this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS probe_candidates_kind_waiting_idx`)
|
|
}
|
|
|
|
async down() {
|
|
this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS probe_candidates_ready_idx`)
|
|
this.schema.raw(`ALTER TABLE probe_candidates DROP COLUMN IF EXISTS ready, DROP COLUMN IF EXISTS unreadable`)
|
|
}
|
|
}
|