데이터베이스 복원 실패: sql 키가 중복되었습니다

안녕하세요. 서버 마이그레이션을 진행 중입니다. 이 과정을 따라 진행했습니다.

CLI를 통해 데이터베이스를 복원하려고 하면 다음 오류가 발생합니다:

CREATE INDEX
ERROR:  could not create unique index "unique_post_links"
DETAIL:  Key (topic_id, post_id, url)=(19891, 32700, http://www.dhl-usa.com/home/home.asp) is duplicated.
EXCEPTION: psql failed: DETAIL:  Key (topic_id, post_id, url)=(19891, 32700, http://www.dhl-usa.com/home/home.asp) is duplicated.
/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'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
script/discourse:290:in `<top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:483:in `exec'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/cli.rb:25:in `start'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/exe/bundle:48:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.7.0/gems/bundler-2.3.18/exe/bundle:36:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Trying to rollback...
Rolling back...
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/var/www/discourse/tmp/restores/default/2022-08-29-194458' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.

포럼은 기존 서버에서 정상적으로 작동하고 있습니다. 읽기 전용 모드로 설정한 뒤 백업을 수행하고, 이를 새 기기로 전송한 후 복원을 시작했습니다.

이 문제를 해결하는 방법에 대한 아이디어가 있을까요?

인덱스가 손상된 것 같습니다. 해당 항목을 삭제하거나 업데이트해야 합니다. 검색해보면, 이 작업을 일반적으로 수행하는 방법에 대해 설명하는 주제들이 아직 남아 있을 수도 있습니다.

오래된 서버에서는 해당 테이블을 다시 인덱싱하고, 성공할 때까지 계속 설정을 변경해 보십시오. SQL에 익숙하지 않고 예산이 있다면 Marketplace 채널에 문의하거나 저에게 연락해 주십시오.

어떤 버전의 Discourse와 Postgres를 사용 중이신가요? Postgres 13 이후에는 이러한 사례를 많이 보지 못했습니다.

제이, 고마워. 연락할게. 지금은 너무 바빠서.