PostgreSQL 13 업데이트 후 업데이트 루프에 갇힘

여기 있는 문서를 읽어 보았지만, 제 상황을 다루지 않습니다: PostgreSQL 13 update

"모든 재빌드 시 업그레이드가 다시 수행되는 상태(즉, 업그레이드 루프)"에 막혀 있습니다:

-------------------------------------------------------------------------------------
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를 사용하여 별도 공유 폴더를 사용하고 있습니다.

이 문제를 해결하기 위해 무엇을 시도해 볼 수 있을까요?

알렉스, 안녕하세요.

재부팅 루프의 원인은 정확히 모르겠지만, 우회할 수 있는 방법이 있을 수 있습니다. postgres_data_new 디렉토리에 데이터베이스가 포함되어 있나요? 그렇다면 해당 디렉토리 안의 PG_VERSION 파일을 확인하여 업그레이드가 정상적으로 수행되었는지 확인해 보세요. 또한 가능하시다면 전체 로그를 복사해서 공유해 주시면 도움이 될 것입니다.

네, postgres_data_new에는 제 데이터베이스가 포함되어 있으며, 그 안의 PG_VERSION 파일에서 버전이 13임을 확인할 수 있습니다.

어떤 로그를 공유해야 도움이 될지(그리고 어디에서 찾을 수 있는지) 확실하지 않습니다.

그 경우, postgres_data_new를 postgres_data 디렉터리로 복사한 후 다시 빌드하면 됩니다. launcher는 데이터베이스가 이미 PG13으로 최신 상태임을 감지하고, 거기서부터 계속 진행합니다.

마이클, 안녕! 처음 여기에 글을 올린 이후로 실제로 시도해 봤다는 걸(두 번이나) 언급하지 않았는데, 아직도 루프에서 빠져나오지 못하고 있어.

./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 템플릿이 아닌가요?

이것이 문제일 수 있습니다.

제이님, 안녕하세요!

맞습니다, 실수였고 유력한 원인으로 보입니다. templates/postgres.template.yml로 변경하고 두 번 다시 빌드해 봤지만 여전히 루프에 갇혀 있습니다.

이 가이드 (아직 유효했을 때)를 따라 DigitalOcean Spaces를 백업 및 이미지 업로드에 사용하도록 설정했습니다.

postgres 데이터가 두 곳에 있는 것 같습니다:

  • /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가 업데이트하는 postgres와 별개의 postgres를 가지고 있는 것처럼 보입니다. Discourse는 /var/postgres_data_discourse의 postgres와는 아무런 관련이 없습니다. 아마도 Discourse가 제공하는 postgres 대신 직접 postgres를 사용하려고 시도한 것일 수 있습니다. 표준 설치 환경으로 보이지 않습니다.

2016년에 설치한 표준 버전이고 그 이후로 계속 업데이트해 왔으니, 그동안 뭔가 변경된 게 있을까요?

볼륨 매핑은 위에 링크한 가이드의 단계를 그대로 따랐습니다.

저는 postgres를 직접 설치해 본 적이 없는 것 같습니다. 왜 그렇게 해야 하는지 알 정도로 기술적으로 숙련되지 않았거든요. :smiley:

postgres 10에서 12로 업데이트하려고 했을 때 "루프 문제(loop problem)"가 발생해서 일단 미뤄두었습니다. 며칠 전에는 아예 리빌드조차 불가능해졌고, 오류 메시지를 보니 postgres와 관련이 있는 것 같아서 문제를 해결할 수 있을지 업데이트를 시도해 보았습니다.

postgres 10 템플릿으로 되돌려서 어떤 오류가 발생하는지 확인해 볼 수 있을까요?

수정: 다른 제안도 환영합니다! 이 시점에서 어떻게 진행해야 할지 모르겠습니다.

첫 번째 게시물에서 이 점을 언급하셨으면 좋았을 텐데 싶습니다.

깔끔하게 재설치를 하고 최신 백업을 복원하는 것이 가장 쉬운 해결책입니다. 운영체제도 오래되었을 가능성이 높습니다.

한 가지 문제를 해결하기 위해 꽤 많은 작업이 필요해 보이지만, 적어도 명확한 해결 방향은 제시해 주셨네요. 이 문제를 해결하는 데 도움을 주셔서 감사합니다, 제이! :folded_hands:

다른 해결책이 없다고 말하는 것은 아닙니다. 다만, 이 무리한 접근 방식은 성공 가능성이 높고 특별한 지식이 필요하지 않습니다. 제가 직접 고친다면 시도해볼 작은 방법들이 몇 가지 있긴 하지만, 여기서 설명하기가 다소 어렵습니다. 특히 어떤 방법을 시도해야 하는지, 혹은 그 방법들이 효과가 있을지 불분명한 상황에서 더욱 그렇습니다.

이 시스템이 2016년에 설치되어 아직 그 운영체제를 사용 중이라면, 운영체제 업그레이드를 진행하기에 아직 이르다고 할 수 없습니다. 그리고 제 생각에는 운영체제 업그레이드를 하는 것보다 새 서버를 새로 세팅하는 것이 훨씬 쉽습니다(15년 전 그 의견을 형성했을 때보다는 지금이 훨씬 그렇지 않을 수 있겠지만요!).