Rasin
(Rasin)
10월 16, 2019, 6:38오전
1
새 서버에 백업을 복원하려 했더니 몇 가지 오류가 발생했습니다.
로그는 여기 있습니다: https://paste.ubuntu.com/p/RDRbX9NRg5/
오류는 아마도 다음과 같습니다:
PG::UniqueViolation: ERROR: could not create unique index "unique_index_categories_on_slug"
DETAIL: Key (COALESCE(parent_category_id, '-1'::integer), slug)=(5, ) is duplicated.
DB 문제인 것 같았지만, 저는 DB를 수정하지 않았습니다. 그냥 백업 tar 파일을 다운로드해서 복원했을 뿐인데 잘못 복원된 것 같습니다.
도와주세요!
ariznaf
(fernando)
10월 16, 2019, 7:02오전
2
유사한 문제를 다루는 다른 스레드가 있습니다.
Strange한 문제입니다.
우리 중 많은 사람들이 계속 시도하는 것만으로 해결했습니다.
여러 번 시도해 보면, 그중 몇 번은 오류가 발생하지 않을 수 있습니다.
당신의 문제는 다를 수 있지만, 복원 과정에서 겪었던 데이터베이스 오류와 유사해 보입니다.
복원 스크립트에 버그가 있거나, 사용된 PostgreSQL 데이터베이스 시스템에 어떤 종류의 버그가 있는 것 같습니다.
Rasin
(Rasin)
10월 16, 2019, 7:12오전
3
이 해결책이 정말 이상하네요…FML
SQL 파일을 편집해서 정상적인 형태로 바꿀 수 있을까요?
즉, 중복된 키를 무시할 수 있는 방법이 있는지요?
Rasin
(Rasin)
10월 16, 2019, 7:57오전
4
이전 버전이나 베타 버전으로 재빌드한 후 로그가 다음과 같이 변했습니다:
EXCEPTION: Compression::Strategy::ExtractFailed[2019-10-16 07:53:52] /var/www/discourse/lib/compression/strategy.rb:89:in `block in extract_file'
/var/www/discourse/lib/compression/strategy.rb:85:in `open'
/var/www/discourse/lib/compression/strategy.rb:85:in `extract_file'
/var/www/discourse/lib/compression/strategy.rb:26:in `block (2 levels) in decompress'
/usr/local/lib/ruby/site_ruby/2.6.0/rubygems/package/tar_reader.rb:65:in `each'
/var/www/discourse/lib/compression/strategy.rb:18:in `block in decompress'
/var/www/discourse/lib/compression/tar.rb:26:in `get_compressed_file_stream'
/var/www/discourse/lib/compression/strategy.rb:15:in `decompress'
/var/www/discourse/lib/compression/pipeline.rb:26:in `block in decompress'
/var/www/discourse/lib/compression/pipeline.rb:24:in `each'
/var/www/discourse/lib/compression/pipeline.rb:24:in `reduce'
/var/www/discourse/lib/compression/pipeline.rb:24:in `decompress'
/var/www/discourse/lib/backup_restore/restorer.rb:141:in `decompress_archive'
/var/www/discourse/lib/backup_restore/restorer.rb:60:in `run'
/var/www/discourse/lib/backup_restore.rb:166:in `block in start!'
/var/www/discourse/lib/backup_restore.rb:163:in `fork'
/var/www/discourse/lib/backup_restore.rb:163:in `start!'
/var/www/discourse/lib/backup_restore.rb:22:in `restore!'
/var/www/discourse/app/controllers/admin/backups_controller.rb:119:in `restore'
이것이 왜 문제가 되는 것인가요? tar 파일에는 아무것도 변경하지 않았는데 말이죠.
Rasin
(Rasin)
10월 16, 2019, 12:46오후
6
이 추출 작업에 대해 정말 감사합니다!
중복된 키 오류에 대해 도움을 주실 수 있을까요? 아니면 psql에서 이 SQL을 수정할 수 있는 방법이 있을까요?
gerhard
(Gerhard Schlager)
10월 16, 2019, 1:39오후
7
Rasin:
오류는 다음과 같습니다:
PG::UniqueViolation: ERROR: could not create unique index "unique_index_categories_on_slug"
DETAIL: Key (COALESCE(parent_category_id, '-1'::integer), slug)=(5, ) is duplicated.
@daniel FIX: Add unique index to prevent duplicate slugs for categories · discourse/discourse@c71da3f · GitHub 의 마이그레이션은 유니크 인덱스를 생성하기 전에 컬럼 값이 고유한지 확인해야 한다고 생각합니다.
daniel
(Daniel Waterworth)
10월 16, 2019, 2:36오후
8
@Rasin , 다음 커밋부터 이제 수정되었습니다:
committed 02:02PM - 16 Oct 19 UTC
Slugs can be the empty string, but the added index didn't account for
that. This… commit changes the migration, stopping it from being unique
so that it can be applied everywhere and adds another migration that
recreates the index properly.
이 문제를 알려주셔서 감사드리며, 불편을 드려 죄송합니다. 다른 문제가 있으시면 알려주세요.
ariznaf
(fernando)
10월 16, 2019, 9:52오후
9
네, 말씀드렸잖아요. 이상한 일이긴 하죠.
하지만 여기에서 읽을 수 있듯이, 우리 중 몇 명에게는 효과가 있었습니다:
Wow, trying to reproduce it so I can be sure that things will go as planned on migration, and I have the error again? I’m going to continue to try and find the steps to reproduce a fix. Because I can’t reproduce it now.
에러가 비슷하지만 완전히 같은 것은 아니므로, 당신의 상황도 동일한지 알 수 없습니다.
@usulrasolas 님은 SQL 문장을 사용하여 스크립트를 수정해 문제를 해결했다고 댓글을 남겼습니다.
하지만 저(와 다른 분들)는 아무것도 변경하지 않고 여러 번 시도해 보았을 뿐입니다.
이상한 일인 건 알지만, 타이밍이나 시간 만료 관련 문제가 관여되어 있을 수도 있습니다.
우리는 알 수 없습니다.
개발자들이 현재 확인하고 있습니다.
Rasin
(Rasin)
10월 17, 2019, 1:22오전
10
제안해 주셔서 감사합니다! 새로운 업데이트를 기대하겠습니다.