Schema migrationsadvancedPro runbook

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.

ProCaptured evidence where the run produced it

Full runbook for this incident

The scenario above is free. What Pro unlocks is the fix: how to identify recover from a failed create index concurrently, the exact SQL to trace it, PostgreSQL 18 output for the steps we captured, the resolution path, and how to stop it recurring.
  • 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.

Compare plans

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.

Open in the interactive map →
ShareLinkedInX

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.

FollowSubstackLinkedInnew errors · lab notes · hiring loops