perf: GPU-job leasing stays O(batch) — partial indexes + two-phase lease #166
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The agent's low throughput was a curator-side defect, not network/hardware.
lease()claimed the lowest-id pending jobs withORDER BY id LIMIT n, but with only a plainstatusindex Postgres walked the primary key from id=1, skipping the entire prefix of already done/error rows before reaching pending ones. With ~69k done, every lease was an O(done) scan → leasing crawled, the DB saturated, and even the/statusGROUP-BY count stalled the agent.lease_expires_at(crash-recovery + orphan sweep). Stay tiny regardless of done/error history.lease()two-phase: claim pending first (id-ordered, O(batch)); reclaim expired leases only when pending can't fill the batch. Same SKIP LOCKED / attempts / reclaim semantics.__table_args__declares the indexes; new test asserts a low-id done-prefix doesn't stop the lease reaching pending.CI green on dev (integration job ran the migration + lease tests).
🤖 Generated with Claude Code