Error on restore: could not create unique index

I am moving our community to a new provider.

CREATE INDEX
CREATE INDEX
ERROR:  could not create unique index "index_incoming_referers_on_path_and_incoming_domain_id"
DETAIL:  Key (path, incoming_domain_id)=(/m/search, 989) is duplicated.
CONTEXT:  parallel worker
EXCEPTION: psql failed: CONTEXT:  parallel worker
/var/www/discourse/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:51:in `run'
script/discourse:149:in `restore'

I tried some previous thoughts on this error:

discourse=# select * from incoming_referers where path LIKE '%/search/' ORDER BY incoming_domain_id;
 id | path | incoming_domain_id
----+------+--------------------
(0 rows)

can anyone help me solve this error?

1 Like

It’s likely a corrupt index. Someone will need to remove or fix the duplicate entries. How to Use amcheck to Check PostgreSQL Index Integrity (Corruption)might help. See also Can't restore due to corrupt indexes (with some clues on how to deal with corrupt indexes).

1 Like