Commit 05f5548
authored
fix(migrations): drop CONCURRENTLY from 0201 indexes (#830)
## Summary
- Switches `0201_backfill_missing_reward_disbursements.sql` from `CREATE
INDEX CONCURRENTLY` to plain `CREATE INDEX` inside the migration's
`BEGIN/COMMIT`.
- Both indexes (`sol_reward_disbursements (challenge_id, specifier)` and
`sol_claimable_accounts (ethereum_address, mint, slot DESC)`) are now
atomic with the backfill INSERT — if anything fails, the schema rolls
back cleanly.
## Why
`CREATE INDEX CONCURRENTLY` waits on a `virtualxid` lock for every
transaction open during its build phases — not just transactions that
touch the target table, but every one in the cluster.
The legacy Python `index_rewards_manager` Celery task on
discovery-provider keeps ~3-minute transactions open against
`challenge_disbursements` continuously. As fast as one ends, another is
already open. So the CONCURRENTLY build can wait indefinitely without
ever seeing a quiet moment — and it did, for 10+ minutes blocked on
`Lock/virtualxid` in tonight's deploy.
Trade-off accepted: regular `CREATE INDEX` takes a `ShareLock` on the
target table for the duration of the build, blocking writes. But both
target tables are written only by the Go indexer, and only on
reward_manager `EvaluateAttestations` and claimable token `Create`
instructions — sparse on-chain. At current row counts each build
completes in seconds; the blocked writes just queue on pgxpool and
resume right after.
## Test plan
- [ ] Cancel any in-flight 0201 attempt and drop any invalid index it
left behind:
```sql
SELECT pg_cancel_backend(pid) FROM pg_stat_activity
WHERE query ILIKE 'CREATE INDEX CONCURRENTLY%';
DROP INDEX IF EXISTS sol_reward_disbursements_challenge_specifier_idx;
DROP INDEX IF EXISTS sol_claimable_accounts_eth_mint_slot_idx;
```
- [ ] Roll the new image; migration Job's `bridge migrate` should
complete in well under a minute.
- [ ] Verify both indexes exist as `indisvalid = true`:
```sql
SELECT indexrelid::regclass, indisvalid FROM pg_index
WHERE indexrelid::regclass::text IN (
'sol_reward_disbursements_challenge_specifier_idx',
'sol_claimable_accounts_eth_mint_slot_idx'
);
```
- [ ] Verify missing-row count drops as expected (per #829's test plan).
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent ff5ea5e commit 05f5548
1 file changed
Lines changed: 20 additions & 11 deletions
Lines changed: 20 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
25 | 36 | | |
26 | | - | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
30 | | - | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
34 | | - | |
35 | | - | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
| |||
0 commit comments