Recover from a failed CREATE INDEX CONCURRENTLY
When CREATE INDEX CONCURRENTLY fails partway, it leaves an INVALID index behind that still costs writes but serves no reads. Find it (indisvalid = f), drop it, and rebuild.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
CREATE INDEX CONCURRENTLY builds in two passes without a strong lock, but if it fails, say on a duplicate key for a unique index, it does not clean up. The leftover index is marked invalid: the planner ignores it for reads, yet every write still maintains it.
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 taking a heavy lock, but if it fails partway, say a unique build hits a duplicate value, it does not tidy up after itself. It leaves behind an index marked invalid: the planner refuses to use it for reads, yet every write still has to maintain it. So you get all of the cost and none of the benefit. The fix is to find the invalid index, drop it, and build again.
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
Card required. Cancel before day 7 and you are not charged.
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.