iamntz
(Ionuț Staicu)
2023 年 1 月 18 日午前 8:16
1
こんにちは。
アップデートと再構築を実行しようとしましたが、この美しいエラーが発生しました。
I, [2023-01-18T08:05:48.701709 #1] INFO -- : cd /var/www/discourse & su discourse -c 'LOAD_PLUGINS=0 bundle exec rake plugin:pull_compatible_all'
I, [2023-01-18T08:05:52.431210 #1] INFO -- :
I, [2023-01-18T08:05:52.431807 #1] INFO -- : cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate'
2023-01-18 08:05:59.081 UTC [1166] discourse@discourse ERROR: could not create unique index "index_tags_on_name_ccnew_ccnew_ccnew5"
2023-01-18 08:05:59.081 UTC [1166] discourse@discourse DETAIL: Key (name)=(vuejs) is duplicated.
2023-01-18 08:05:59.081 UTC [1166] discourse@discourse STATEMENT: REINDEX INDEX CONCURRENTLY index_tags_on_name_ccnew_ccnew
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
PG::UniqueViolation: ERROR: could not create unique index "index_tags_on_name_ccnew_ccnew_ccnew5"
DETAIL: Key (name)=(vuejs) is duplicated.
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `async_exec'
フォーラムには同様の問題に関する他のトピックがあります(1 、2 、3 )が、コンテナに入ろうとすると、次のようになります。
/var/discourse# ./launcher enter app
x86_64 arch detected.
Error: No such container: app
そのため、インデックスを手動で削除できません。
他にどのようなアプローチを取るべきか、何か提案はありますか?
「いいね!」 2
nbianca
(Bianca)
2023 年 1 月 18 日午前 8:59
2
こんにちは、Ionutさん。
バグレポートありがとうございます。確認してみます。しかし、データベースのインデックスに問題があり、最近のマイグレーションでそれを修正しようとしていますが、人間の介入なしには修正できない問題もあります。
失敗したマイグレーションを導入したコミットはこれだと思われます。
committed 03:04AM - 13 Jan 23 UTC
In Discourse, there are many migration files where we CREATE INDEX CONCURRENTLY … which requires us to set disable_ddl_transaction!. Setting disable_ddl_transaction! in a migration file runs the SQL statements outside of a transaction. The implication of this is that there is no ROLLBACK should any of the SQL statements fail.
We have seen lock timeouts occuring when running CREATE INDEX CONCURRENTLY. When that happens, the index would still have been created but marked as invalid by Postgres.
Per the postgres documentation:
> If a problem arises while scanning the table, such as a deadlock or a uniqueness violation in a unique index, the CREATE INDEX command will fail but leave behind an “invalid” index. This index will be ignored for querying purposes because it might be incomplete; however it will still consume update overhead.
> The recommended recovery method in such cases is to drop the index and try again to perform CREATE INDEX CONCURRENTLY . (Another possibility is to rebuild the index with REINDEX INDEX CONCURRENTLY ).
When such scenarios happen, we are supposed to either drop and create the index again or run a REINDEX operation. However, I noticed today that we have not been doing so in Discourse. Instead, we’ve been incorrectly working around the problem by checking for the index existence before creating the index in order to make the migration idempotent. What this potentially mean is that we might have invalid indexes which are lying around in the database which PG will ignore for querying purposes.
This commits adds a migration which queries for all the
invalid indexes in the `public` namespace and reindexes them.
代わりに、Discourseインスタンスを前のバージョンであるコミット 690e2f15ab9549486aaa6750e1093c1336bf17f2 にピン留めしてみてください。app.yml ファイルを編集し、paramsの下のversionキー を設定してください。そのキーのコメントアウトも解除してください。
そうすれば、すべてが開始され、重複した vuejs タグを削除できるようになるはずですが、重複したタグが使用されている場合、予期しない影響がある可能性があります。より良い解決策を見つけようとしますが、それまではこれでうまくいくはずです。
「いいね!」 2
iamntz
(Ionuț Staicu)
2023 年 1 月 18 日午前 11:31
3
起動後、Data Explorer プラグインを使用してすべての重複タグを見つけることができました。
SELECT name, count(*)
FROM tags
GROUP BY name
HAVING count(*) > 1
何らかの理由で、約10個 の重複タグがありました。なぜ、そしてどのようにそれらがそもそも そこにあったのか不思議です…
それらをすべて削除し、yml ファイルからバージョンロックを解除し、再構築したところ、すべて問題なく動作するようになりました。
ありがとうございました!
「いいね!」 5
sam
(Sam Saffron)
2023 年 1 月 18 日午後 10:50
4
過去にも同様の事例があり、悪夢のような問題でしたが、アップグレードに関連していることが特定されました。
PGのインデックス構造は、インストール時のロケールに依存し、アップグレードは時に悪夢のような結果を招くことがあります。
opened 09:42PM - 17 May 19 UTC
closed 06:18PM - 16 Jun 21 UTC
See https://lists.debian.org/debian-glibc/2019/03/msg00030.html, https://bugs.de… bian.org/926627, and https://salsa.debian.org/ddp-team/release-notes/commit/ad75c4b for some context.
> When upgrading from stretch to buster, the glibc locale data is upgraded.
> Specifically, this changes how PostgreSQL sorts data in text indexes.
> To avoid corruption, such indexes need to be `REINDEX`ed
> immediately after upgrading the `locales` or
> `locales-all` packages, before putting back the database
> into production.
>
> Suggested command: `sudo -u postgres reindexdb --all`
I'm not entirely sure how we're going to handle this, but it does mean it won't be reasonable for us to simply upgrade the images from Stretch to Buster once Buster is released. :confused: :disappointed:
再インデックスが十分な早期に実行されないと、問題が発生する可能性があります。以前のPG Dockerアップグレードの一部ではこれが実行されず、古いインストールには残念ながら時限爆弾のようなものが残っています。
現在ではエコシステムの大半で解決されていますが、一部の苦痛は残っています。
「いいね!」 2
iamntz
(Ionuț Staicu)
2023 年 1 月 19 日午後 3:30
5
原因の特定に役立つかもしれないので、システムに関する詳細を以下に示します。
インストールは確かに古く、2014年からですが、システムは少なくとも月に一度(通常は隔週)更新されています。そのため、メジャーバージョンがスキップされたことはありません。
バージョンロックはないため、基本的に main ブランチで利用可能な最新バージョンで実行しています(YOLO!)。
以前に非公式のものをいくつか試したことはありますが、インストールされているプラグインはすべて公式のもので、過去5年以上そうでした。
「いいね!」 1
uwe_keim
(Uwe Keim)
2023 年 1 月 20 日午後 4:38
6
Ionuț Staicu:
なんとかそれらを削除しました
私も同じ問題を抱えています。この文まであなたの手順に従いました。
重複を実際に削除するにはどうすればよいですか?Data Explorerで単にdelete SQLステートメントを実行するのですか?このタグを指している外部テーブルのレコードはどうなりますか?
更新1
わかりました、updateステートメントを実行できないことがわかりました。
GUIを使用してタグの名前を変更しました。
iamntz
(Ionuț Staicu)
2023 年 1 月 20 日午後 8:29
7
タグを編集する(/tag/fooに移動して)か、名前を変更するか、削除してください。
system
(system)
クローズされました:
2023 年 2 月 19 日午後 8:29
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.