# "EXCEPTION: psql failed: DETAIL: Key (post\_id)=(36946) is duplicated."

**URL:** <https://meta.discourse.org/t/exception-psql-failed-detail-key-post-id-36946-is-duplicated/230356>\
**Category:** Self-hosting\
**Created:** [June 18, 2022, 5:24am UTC](https://meta.discourse.org/t/exception-psql-failed-detail-key-post-id-36946-is-duplicated/230356 "2022-06-18T05:24:27Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MiG](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mig/32/119486_2.png) [@MiG](https://meta.discourse.org/u/MiG)\
**Post date:** [June 20, 2022, 6:15pm UTC](https://meta.discourse.org/t/exception-psql-failed-detail-key-post-id-36946-is-duplicated/230356/7 "2022-06-20T18:15:32Z")

</div>

Thanks for the help, guys.

I was able to do the following:

```plaintext
discourse=# reindex index concurrently "posts_search_pkey";
ERROR: could not create unique index "posts_search_pkey_ccnew2"
DETAIL: Key (post_id)=(116038) is duplicated.
discourse=# delete from post_search_data
where post_id = 116038;
DELETE 2
discourse=# delete from post_search_data
where post_id = 116038;
DELETE 0
discourse=# reindex index concurrently "posts_search_pkey";
ERROR: could not create unique index "posts_search_pkey_ccnew3"
DETAIL: Key (post_id)=(9336) is duplicated.
discourse=# delete from post_search_data
where post_id = 9336;
DELETE 1
.
.
.
.
discourse=# reindex index concurrently "posts_search_pkey";
REINDEX

```

Once everything seemed ok, I did a full backup and restored it on a new server with no issues.

I appreciate everyone’s time. I love discourse!

Lesson learned: check backups once in a while to be sure they’re good 🙂 I keep daily backups, and then keep monthly “snapshots” too. The earliest backup I had that didn’t have a corrupted database was 4 months old ☹

---

_[View the full topic](https://meta.discourse.org/t/exception-psql-failed-detail-key-post-id-36946-is-duplicated/230356)._
