Commit a06000a
committed
Recover invalid concurrent indexes on migration retry
An interrupted CREATE INDEX CONCURRENTLY leaves a same-name INVALID index
behind; IF NOT EXISTS then sees the relation and skips creation, so a
retried migration completes with an index that serves no queries. For
uq_experiments_shadow_of_live that silently breaks the shadow creator's
INSERT .. ON CONFLICT arbiter inference, which only considers valid
indexes. Before each concurrent CREATE, drop a same-name index whose
pg_index.indisvalid is false so the CREATE rebuilds it.
Drilled against Postgres 16: corrupting both indexes and rerunning the
unfixed migrations left indisvalid=f and the ON CONFLICT insert failing
with "no unique or exclusion constraint matching"; with this change the
rerun rebuilds both (indisvalid=t) and the conflict path dedupes again.
Claude-Session: https://claude.ai/code/session_01ACF6SUXdbLFarpj3qwF1Ki1 parent a2912d6 commit a06000a
2 files changed
Lines changed: 55 additions & 0 deletions
File tree
- oddish/alembic/versions
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
32 | 60 | | |
33 | 61 | | |
34 | 62 | | |
| |||
41 | 69 | | |
42 | 70 | | |
43 | 71 | | |
| 72 | + | |
44 | 73 | | |
45 | 74 | | |
46 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
33 | 58 | | |
34 | 59 | | |
35 | 60 | | |
| |||
47 | 72 | | |
48 | 73 | | |
49 | 74 | | |
| 75 | + | |
50 | 76 | | |
51 | 77 | | |
52 | 78 | | |
| |||
0 commit comments