postgres アップグレード中の無限ループ

Hi! Each time I launch /launcher rebuild app I get the following message (even if I launch it again) :

UPGRADE OF POSTGRES COMPLETE
Old 9.5 database is stored at /shared/postgres_data_old
To complete the upgrade, rebuild again using:
./launcher rebuild app

What information do you need to help me?

PS: The first time I ran it, the command stoped because I needed more space

Temporarily, I used the templates/postgres.9.5.template.yml template to avoid downtime. The app is running again, but I’d like to finish the update.

When I do a cleanup I get the following message : Old PostgreSQL backup data cluster detected taking up 1.2G detected. Would you like to remove it? (Y/n):

Sounds like a question for @tgxworld, but I am guessing that it failed due to lack of space but somehow didn’t catch that the upgrade had failed.

How much space do you have? And how big is your database?

「いいね!」 1

Can you provide me with the full log generated during the rebuild? Thank you!

「いいね!」 3

数ヶ月間同じ問題に直面しており、インストールのアップグレードができません。

ループが発生し、成功することがありません。rebuild app の間に発生する問題の一つは次の通りです:
mv: cannot move '/shared/postgres_data' to '/shared/postgres_data_old': Device or resource busy

Docker 内で確認した PostgreSQL のバージョンは以下の通りです:

/usr/lib/postgresql/10/bin/postgres --version
postgres (PostgreSQL) 10.14 (Debian 10.14-1.pgdg100+1)

以下がエラーメッセージです:

FAILED

--------------------

Pups::ExecError: /root/upgrade_postgres failed with return #<Process::Status: pid 47 exit 1>

Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'

exec failed with the params "/root/upgrade_postgres"

0c74c9de4d4315b63c0ef9055631f38c0cf4b3dd0be6500fd83ca0a5b13e0d9d

** FAILED TO BOOTSTRAP ** 上記にスクロールして、それ以前のエラーメッセージを確認してください。複数のエラーが含まれている可能性があります。

./discourse-doctor で問題の診断に役立つかもしれません。

/pups/lib/pups/exec_command.rb スクリプト内で spawn が実行される際に問題が発生しているようです。

ただし、アプリは起動できます:
./launcher start app

/shared 配下に存在するファイルは以下の通りです:

total 48
drwxr-xr-x 12 root      root     4096 Jan 12 13:12 .
drwxr-xr-x 57 root      root     4096 Dec 15 09:09 ..
drwxr-xr-x  3 discourse www-data 4096 Aug 20  2019 backups
drwxr-xr-x  4 root      root     4096 Aug 19  2019 log
drwxr-xr-x  2 postgres  postgres 4096 Aug 19  2019 postgres_backup
drwx------ 20 postgres  postgres 4096 Jan 12 13:14 postgres_data
drwx------ 19 postgres  postgres 4096 Jan 12 13:12 postgres_data_new
drwxrwxr-x  5 postgres  postgres 4096 Jan 12 13:14 postgres_run
drwxr-xr-x  2 redis     redis    4096 Jan 12 13:07 redis_data
drwxr-xr-x  4 root      root     4096 Aug 19  2019 state
drwxr-xr-x  4 discourse www-data 4096 Jan 12 13:14 tmp
drwxr-xr-x  4 discourse www-data 4096 Sep  8  2019 uploads

どうすればよいでしょうか?

共有ディレクトリは何かしらのネットワークマウントでしょうか?

「いいね!」 1

いいえ、でもついに成功しました!

templates/postgres.template.yml 内の 2 つの mv コマンドは正常かどうかチェックされていません。スクリプトは常に UPGRADE OF POSTGRES COMPLETE と表示されますが、移動にエラーがあった場合は実際には完了していません。

コマンドを削除し、Docker 内で手動でディレクトリを移動したところ、次の rebuild app が以前通り正常に動作しています!とても嬉しいです :smiley:
ありがとうございます。

「いいね!」 3

PostgreSQL 13から15への最新のアップグレード中にこの問題が発生しました。

私たちのデプロイメントでは、/shared/postgres_dataディレクトリはより高速なNVMeストレージデバイスにマウントされているため、Device or resource busyというエラーメッセージが表示されて移動に失敗しました。

以下のようにpostgresテンプレートをパッチすることでこれを修正しました。

diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml
index c24bfe6..03813c4 100644
--- a/templates/postgres.template.yml
+++ b/templates/postgres.template.yml
@@ -139,8 +139,10 @@ run:
            exit 1
          fi

-         mv /shared/postgres_data /shared/postgres_data_old
-         mv /shared/postgres_data_new /shared/postgres_data
+         mkdir /shared/postgres_data_old
+         mv /shared/postgres_data/* /shared/postgres_data_old
+         mv /shared/postgres_data_new/* /shared/postgres_data
+         rmdir /shared/postgres_data_new

ディレクトリ自体を操作しようとする代わりに、コンテンツを移動させます。

データベースアップグレードの信頼性を向上させるために、この変更を統合することを検討してください。

「いいね!」 1

これに関連しているかもしれません: FIX: improve postgres upgrade reliability by jcharaoui · Pull Request #989 · discourse/discourse_docker · GitHub

「いいね!」 2

PRはマージされました :+1:

「いいね!」 1

このトピックは6日後に自動的に閉じられました。返信はもう許可されていません。