Recover from a failed CREATE INDEX CONCURRENTLY
When CREATE INDEX CONCURRENTLY fails, it leaves an INVALID index behind. The planner never uses it, and depending on where the build stopped, writes may still have to deal with it. Check its state (indisvalid, indisready), fix the cause, then drop and rebuild or REINDEX it.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
CREATE INDEX CONCURRENTLY builds without blocking writes, but if it fails (for example, a unique build hits a duplicate key) or is cancelled, it does not clean up after itself. The leftover index stays in the catalog marked invalid (indisvalid = f), and the planner will not use it for reads. What it costs depends on how far the build got. If it failed during the initial build (indisready = f), it is empty, but it still stops HOT updates on its columns. If it failed later (indisready = t), every INSERT and UPDATE keeps maintaining it, and a unique leftover still rejects duplicate keys.
Meridian's concurrent unique-index build on courier_emails fails because of a duplicate address. An invalid index is left behind and must be cleaned up before retrying.
Simple terms
CREATE INDEX CONCURRENTLY builds without blocking writes, but if it fails partway it does not tidy up after itself. It leaves behind an index marked invalid, which the planner will never use for reads. If the build died early, the leftover is empty but still blocks a write optimisation (HOT updates) on that column. If it died late, every write keeps maintaining it, and a unique leftover still rejects duplicates. Either way you pay a cost and get no benefit. The fix: find out why it failed, fix that, then drop and rebuild it (or REINDEX it).
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
More in this category
Other Schema migrations runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.