8 lines · 506 B
-- `backfilling` counts import relays in flight; this bounds how long that count is trusted, so a relay whose
-- decrement never ran (an evicted isolate) can't leave the repository in import mode forever.
ALTER TABLE repos ADD COLUMN backfill_expires_at INTEGER;

-- Rows already counting a relay get a window, so one whose decrement was lost heals instead of staying forever.
UPDATE repos SET backfill_expires_at = CAST(strftime('%s', 'now') AS INTEGER) * 1000 + 6 * 60 * 60 * 1000
WHERE backfilling > 0;