PostgreSQL 13のアップデート後、アップデートループに陥っています

ドキュメント(https://meta.discourse.org/t/postgresql-13-update/172563/1)を確認しましたが、私の状況については記載されていませんでした。

「すべての再構築でアップグレードが再度実行される(アップグレードループ)」という問題でつまずいています:

-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 10 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------

ドキュメントでは、これは「最後のアップグレードからのファイルがまだ残っているため」とされており、「続行する前にそれらを別の場所へ移動させてください」と説明されています。

しかし、古いファイルは存在しません:

root@connect:/var/discourse# ls /mnt/volume_ams3_01/shared/standalone/
backups  letsencrypt  log  postgres_backup  postgres_data  postgres_data_new  postgres_run  redis_data  ssl  state  tmp  uploads

補足として:

  • postgres_data フォルダは空です。
  • DigitalOcean Spaces を使用した独立した共有フォルダを持っています。

これを解決するために何が試せるでしょうか?

こんにちは、Alex さん。

再起動ループの原因は特定できていませんが、回避策を試せるかもしれません。postgres_data_newディレクトリにデータベースが含まれているでしょうか?もしそうであれば、そのディレクトリ内の PG_VERSION ファイルを確認して、アップグレードが正常に完了したかチェックしてみてください。また、可能であれば完全なログをコピーして共有していただけると助かります。

「いいね!」 2

はい、postgres_data_new には私のデータベースが含まれており、その中の PG_VERSION でバージョンが 13 であることが確認できます。

共有すべきログが何で、どこに保存されているのかわかりません。

その場合、postgres_data_newpostgres_data ディレクトリにコピーして、再ビルドを行ってください。launcher はデータベースがすでに PG13 に対応していることを検知し、そこから処理を継続します。

「いいね!」 1

マイケルさん、こんにちは!元々ここに投稿してから、その方法を試してみたことをお伝えし忘れていました(2回試しました)。まだ同じ状態から抜け出せていません。

「いいね!」 1

./launcher rebuild app の出力をどのようにキャプチャすればよいかわかりませんが、私が取得したものを以下に示します。

最初は次のようになります。

root@connect:/var/discourse# ./launcher rebuild app
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 60 app
app
cd /pups && git pull && git checkout v1.0.3 && /pups/bin/pups --stdin
From https://github.com/discourse/pups
   17f04ec..e0ff889  master     -> origin/master
 * [new tag]         v1.1.1     -> v1.1.1
 * [new tag]         v1.1.0     -> v1.1.0
Updating 17f04ec..e0ff889
Fast-forward
 .github/workflows/ci.yml     |  29 ++++++
 .github/workflows/lint.yml   |  27 +++++
 .rubocop.yml                 |   3 +
 Gemfile                      |   2 +
 Guardfile                    |   4 +-
 README.md                    |  21 ++++
 Rakefile                     |  14 +--
 bin/pups                     |   8 +-
 lib/pups.rb                  |  32 ++++--
 lib/pups/cli.rb              |  92 ++++++++++-------
 lib/pups/command.rb          |  25 +++--
 lib/pups/config.rb           | 240 +++++++++++++++++++++++--------------------
 lib/pups/docker.rb           |  69 +++++++++++++
 lib/pups/exec_command.rb     | 182 ++++++++++++++++----------------
 lib/pups/file_command.rb     |  60 +++++------
 lib/pups/merge_command.rb    |  94 ++++++++---------
 lib/pups/replace_command.rb  |  70 +++++++------
 lib/pups/runit.rb            |  47 +++++----
 lib/pups/version.rb          |   4 +-
 pups.gemspec                 |  37 ++++---
 test/cli_test.rb             | 102 +++++++++++++++---
 test/config_test.rb          | 215 ++++++++++++++++++++++++++++----------
 test/docker_test.rb          | 157 ++++++++++++++++++++++++++++
 test/exec_command_test.rb    |  62 ++++++-----
 test/file_command_test.rb    |  17 ++-
 test/merge_command_test.rb   |  64 ++++++------
 test/replace_command_test.rb |  86 ++++++++--------
 test/test_helper.rb          |   2 +
 28 files changed, 1158 insertions(+), 607 deletions(-)
 create mode 100644 .github/workflows/ci.yml
 create mode 100644 .github/workflows/lint.yml
 create mode 100644 .rubocop.yml
 create mode 100644 lib/pups/docker.rb
 create mode 100644 test/docker_test.rb
Note: checking out 'v1.0.3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at d1db030 cut a new version
I, [2021-10-19T05:37:44.995716 #1]  INFO -- : Loading --stdin
I, [2021-10-19T05:37:45.001857 #1]  INFO -- : > locale-gen $LANG && update-locale
I, [2021-10-19T05:37:45.031533 #1]  INFO -- : Generating locales (this might take a while)...
Generation complete.

I, [2021-10-19T05:37:45.032260 #1]  INFO -- : > mkdir -p /shared/postgres_run
I, [2021-10-19T05:37:45.037403 #1]  INFO -- :
I, [2021-10-19T05:37:45.038002 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run
I, [2021-10-19T05:37:45.041480 #1]  INFO -- :
I, [2021-10-19T05:37:45.041974 #1]  INFO -- : > chmod 775 /shared/postgres_run
I, [2021-10-19T05:37:45.044313 #1]  INFO -- :
I, [2021-10-19T05:37:45.044759 #1]  INFO -- : > rm -fr /var/run/postgresql
I, [2021-10-19T05:37:45.047047 #1]  INFO -- :
I, [2021-10-19T05:37:45.047605 #1]  INFO -- : > ln -s /shared/postgres_run /var/run/postgresql
I, [2021-10-19T05:37:45.051062 #1]  INFO -- :
I, [2021-10-19T05:37:45.051463 #1]  INFO -- : > socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
2021/10/19 05:37:45 socat[33] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory
I, [2021-10-19T05:37:45.058669 #1]  INFO -- :
I, [2021-10-19T05:37:45.058976 #1]  INFO -- : > rm -fr /shared/postgres_run/.s*
I, [2021-10-19T05:37:45.061427 #1]  INFO -- :
I, [2021-10-19T05:37:45.061743 #1]  INFO -- : > rm -fr /shared/postgres_run/*.pid
I, [2021-10-19T05:37:45.063969 #1]  INFO -- :
I, [2021-10-19T05:37:45.064258 #1]  INFO -- : > mkdir -p /shared/postgres_run/13-main.pg_stat_tmp
I, [2021-10-19T05:37:45.068148 #1]  INFO -- :
I, [2021-10-19T05:37:45.068570 #1]  INFO -- : > chown postgres:postgres /shared/postgres_run/13-main.pg_stat_tmp
I, [2021-10-19T05:37:45.070400 #1]  INFO -- :
I, [2021-10-19T05:37:45.074243 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown:
I, [2021-10-19T05:37:45.077577 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown:
I, [2021-10-19T05:37:45.081084 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown:
I, [2021-10-19T05:37:45.084463 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown:
I, [2021-10-19T05:37:45.084841 #1]  INFO -- : > chown -R root /var/lib/postgresql/13/main
I, [2021-10-19T05:37:45.766251 #1]  INFO -- :
I, [2021-10-19T05:37:45.766560 #1]  INFO -- : > [ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres /usr/lib/postgresql/13/bin/initdb -D /shared/postgres_data || exit 0
I, [2021-10-19T05:37:45.769955 #1]  INFO -- :
I, [2021-10-19T05:37:45.770597 #1]  INFO -- : > chown -R postgres:postgres /shared/postgres_data
I, [2021-10-19T05:37:45.841916 #1]  INFO -- :
I, [2021-10-19T05:37:45.842605 #1]  INFO -- : > chown -R postgres:postgres /var/run/postgresql
I, [2021-10-19T05:37:45.845109 #1]  INFO -- :
I, [2021-10-19T05:37:45.845574 #1]  INFO -- : > /root/upgrade_postgres
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
debconf: delaying package configuration, since apt-utils is not installed

その後、/shared/postgres_data/base/whatever にある多くの行とともに非常に速く進み、以下のように終わります。

  /shared/postgres_data/base/16400/203028
  /shared/postgres_data/base/16400/203045
  /shared/postgres_data/base/16400/203047
  /shared/postgres_data/base/16400/203049
  /shared/postgres_data/base/16400/203050
  /shared/postgres_data/base/13014/2613
  /shared/postgres_data/base/13014/2683
  /shared/postgres_data/base/1/2613
  /shared/postgres_data/base/1/2683
                                                            ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to analyze new cluster                      ok
Creating script to delete old cluster                       ok

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    ./analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 10 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------

a68ed0b1b54e4a0e2dae2543dc27d87be02ca1f81738e0d2e43511a46524a980

containers/app.yml に含めているテンプレートについて教えていただけますか?

はい、以下の通りです:

templates:
  # - "templates/postgres.10.template.yml"
  - "templates/postgres.13.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.replygif.template.yml" # ReplyGIF プラグイン用: https://github.com/cpradio/discourse-plugin-replygif

(ReplyGIF のテンプレートは使用しないため、コメントアウトします。)

これはどういう意味でしょうか?関連している可能性が高いと思います。

なぜ「13」が付かない単なる postgres テンプレートではないのでしょうか?

これが問題の原因かもしれません。

「いいね!」 1

こんにちは、Jay!

その通りです、それは間違いのようで、原因として有力ですね。templates/postgres.template.yml に変更し、2 回再構築しましたが、まだループから抜け出せていません。

バックアップと画像のアップロードに DigitalOcean Spaces を使用するために、このガイド(利用可能だった当時)に従いました。

私の postgres データは 2 つの場所にあるようです:

  • /var/postgres_data_discourse(PG_VERSION = 10)
  • /mnt/volume_ams3_01/shared/standalone/postgres_data_new(PG_VERSION = 13)
  • /mnt/volume_ams3_01/shared/standalone/postgres_data(PG_VERSION = 13)– 以前提案された通り、これらのファイルを postgres_data_new から手動でコピーしました

現時点での私の推測では、これはボリュームマッピングに関連していると思われます。

しかし、上記を見ると、Discourse が更新している PostgreSQL とは別の PostgreSQL が存在しているように見えます。Discourse は /var/postgres_data_discourse にある PostgreSQL とは関係ありません。Discourse が提供するものではなく、独自の PostgreSQL を使用しようとしたのではないでしょうか?これは標準的なインストールではないようです。

「いいね!」 1

これは2016年の標準的なインストールで、それ以来更新を続けています。その間に何か変更があったのかもしれませんね?

ボリュームマッピングについては、上記でリンクしたガイドの手順に従いました。

自分でPostgreSQLをインストールしようとしたことはないと考えています。なぜそうしたいのか、技術的に理解していないためです :smiley:

PostgreSQL 10から12への更新を試した際に「ループ問題」が発生したことは確かです。そのため、その件は後回しにしていました。数日前には全くビルドできなくなり、エラーメッセージからPostgreSQLが原因だと推測し、更新を試みました。もしかしたら問題が解決するかもしれないと思ったからです。

PostgreSQL 10のテンプレートに戻して、どのようなエラーが発生するか確認することは可能でしょうか?

追記:他のご提案も歓迎します!現時点でどう進めればよいか確信が持てません。

最初の投稿でそのことを言及しておけばよかったかもしれませんね。

クリーンインストールを行い、最新のバックアップから復元することをお勧めします。それが最も簡単な解決策です。また、お使いの OS もおそらく outdated な状態だと思われます。

「いいね!」 2

1 つの問題を解決するためにこれほど手間がかかるのは大変そうですが、少なくとも具体的な解決策が示されました。この件についてサポートしてくださり、Jay さん、ありがとうございます!:folded_hands:

あなたの状況から抜け出す別の方法がないと言っているわけではありませんが、このハンマーのようなアプローチは成功率が高く、特別な知識も必要としません。もし私が修正する立場なら、いくつかの小さな方法を試すかもしれませんが、それらはここで説明するのが非常に難しく、特にどの方法を試すべきか、あるいは効果が期待できるかどうかが不明な場合です。

もしこのシステムが2016年にセットアップされ、今も同じOSを使用しているなら、OSのアップグレードを検討する時期は早すぎるということはありません。個人的な見解ですが、OSのアップグレードを行うよりも、新しいサーバーを立ち上げる方がはるかに簡単です(この意見は15年前に形成されたもので、現在は状況が異なるかもしれません)。

「いいね!」 2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.