# Rebuilding invalid indexes

**URL:** https://meta.discourse.org/t/rebuilding-invalid-indexes/177599
**Category:** Self-hosting
**Created:** [January 28, 2021, 8:45pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599 "2021-01-28T20:45:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 28, 2021, 8:45pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599/1 "2021-01-28T20:45:54Z")

</div>

I just upgraded a 1.8 million post site to 2.7.0.beta2 and with it the PG10 to PG13 upgrade. I saw that beta3 just came out and has “improved database migration performance” so I went ahead and upgraded again.

When I try to do a `reindex concurrently`, I get

```plaintext
WARNING: cannot reindex invalid index "public.allowed_pm_users_pkey_ccnew" concurrently, skipping
WARNING: cannot reindex invalid index "public.index_allowed_pm_users_on_user_id_and_allowed_pm_user_id_ccnew" concurrently, skipping
WARNING: cannot reindex invalid index "public.index_allowed_pm_users_on_allowed_pm_user_id_and_user_id_ccnew" concurrently, skipping

```

I was going to drop and reindex those, but I don’t see any `ccnew` in the current source, so I’m not sure what to do.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [January 28, 2021, 8:49pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599/2 "2021-01-28T20:49:27Z")

</div>

[Looks like](https://paquier.xyz/postgresql-2/postgres-12-reindex-concurrently/) the `_ccnew` index is part of how the concurrent reindex happens:

> - Create a new index in the catalogs which is a copycat of the one reindexed (with some exceptions, for example partition indexes don’t have their inheritance dependency registered at creation, but at swap time). This new, temporary is suffixed with “\_ccnew”. Bref.

Can you reindex those indexes without the `concurrently` keyword?

or, from later in that post:

> Then, REINDEX TABLE CONCURRENTLY will _skip_ invalid indexes because in the event of successive and multiple failures then the number of indexes would just ramp up, doubling at each run, causing a lot of bloat on the follow-up reindex operations:  
> …  
> It is however possible to reindex invalid indexes with just REINDEX INDEX CONCURRENTLY:

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 28, 2021, 8:54pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599/3 "2021-01-28T20:54:55Z")

</div>

`_ccnew` are indexes that were tried to be created by a previous `reindex concurrently` but couldn’t be done, usually because they are violating a uniqueness check. The failed attempts to `reindex concurrently` will sit in there and should be dropped manually.

The second time you run `reindex concurrently`, PostgreSQL will skip those failure artifacts.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 28, 2021, 9:47pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599/4 "2021-01-28T21:47:22Z")

</div>

Thanks Rafael! That did it. I `drop`ped those indexes and did another concurrent reindex with no issues.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 27, 2021, 9:47pm UTC](https://meta.discourse.org/t/rebuilding-invalid-indexes/177599/5 "2021-02-27T21:47:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
