Rasin
(Rasin)
2019 年 10 月 16 日午前 6:38
1
新しいサーバーにバックアップを復元しようとしたところ、いくつかのエラーが表示されました。
ログはこちらです:Ubuntu Pastebin
エラーの原因はおそらく以下の通りです:
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.
データベースの問題だと思いましたが見直したわけではありません。バックアップの tar ファイルをダウンロードしただけで、復元方法が間違っていたようです。
お手数ですが、ご支援をお願いします!
ariznaf
(fernando)
2019 年 10 月 16 日午前 7:02
2
似たような問題についての別のスレッドがあります。
奇妙な問題ですね。
私たちの多くは、単に何度も試すことで解決しました。
数回試してみてください。そのうちの一つでエラーが出なくなるかもしれません。
あなたの問題が異なる可能性もありますが、復元中に私たちが経験したデータベースエラーに似ています。
復元スクリプトにバグがあるか、使用されている PostgreSQL データベースシステムに何らかのバグがあるようです。
Rasin
(Rasin)
2019 年 10 月 16 日午前 7:12
3
この解決策、なんて奇妙なんだろう…本当に困った
SQLファイルを編集して、通常の状態に戻すことは可能でしょうか?
つまり、重複キーを無視する方法はありますか?
Rasin
(Rasin)
2019 年 10 月 16 日午前 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)
2019 年 10 月 16 日午後 12:46
6
この抽出作業、本当にありがとうございます!
重複キーのエラーについてお手伝いいただけますか?それとも、psql でこの SQL を修正する方法はありますか?
gerhard
(Gerhard Schlager)
2019 年 10 月 16 日午後 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)
2019 年 10 月 16 日午後 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)
2019 年 10 月 16 日午後 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)
2019 年 10 月 17 日午前 1:22
10
ご提案ありがとうございます!新しいアップデートを楽しみにしています。