“./launcher rebuild app” 실행 시 db:migrate에서 실패합니다. 참고로 PostgreSQL v12를 사용하고 있습니다.
이 문제로 인해 포럼이 망가졌습니다. Docker 컨테이너는 다시 시작되었지만, 포럼은 작동하지 않았습니다. 다행히 업그레이드 전에 VM 스냅샷을 찍어두었기 때문에 지금 이를 복원하고 있습니다.
로그:
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I, [2022-04-14T15:20:51.896917 #1] INFO -- : == 20220304162250 EnableUnaccentExtension: migrating ==========================
-- enable_extension("unaccent")
I, [2022-04-14T15:20:51.897218 #1] INFO -- : Terminating async processes
I, [2022-04-14T15:20:51.897265 #1] INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/12/bin/postmaster -D /etc/postgresql/12/main pid: 1710
I, [2022-04-14T15:20:51.897396 #1] INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 1827
2022-04-14 15:20:51.897 UTC [1710] LOG: received fast shutdown request
1827:signal-handler (1649949651) Received SIGTERM scheduling shutdown...
2022-04-14 15:20:51.900 UTC [1710] LOG: aborting any active transactions
2022-04-14 15:20:51.902 UTC [1710] LOG: background worker "logical replication launcher" (PID 1719) exited with exit code 1
2022-04-14 15:20:51.904 UTC [1714] LOG: shutting down
1827:M 14 Apr 2022 15:20:51.913 # User requested shutdown...
1827:M 14 Apr 2022 15:20:51.914 * Saving the final RDB snapshot before exiting.
2022-04-14 15:20:51.965 UTC [1710] LOG: database system is shut down
1827:M 14 Apr 2022 15:20:53.157 * DB saved on disk
1827:M 14 Apr 2022 15:20:53.157 # Redis is now ready to exit, bye bye...
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 2118 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
2dcd9aeca614c9e06ef748f673eb68203db6eae5c445253b416d666663879d6d
==================== END REBUILD LOG ====================
Failed to rebuild app.
이 확장 프로그램은 PostgreSQL 13 이상에서 “신뢰할 수 있는”(trusted) 확장으로 사용 가능하며, 이 경우 모든 사용자가 활성화할 수 있습니다.
현재 구버전의 PostgreSQL을 사용 중이므로, Discourse 사용자를 위해 이 확장 프로그램을 설치하고 활성화하는 우회 방법을 사용해야 합니다. 또한 Discourse가 이 확장 프로그램이 이미 설치된 것으로 인식하도록 속이는 방법을 시도해 볼 수도 있습니다. 아니면 현재 지원되는 PostgreSQL 버전으로 업그레이드하는 것이 좋습니다.
안녕하세요. Discourse 백업이 있다면, 먼저 다른 서버에서 테스트해 보시는 것을 권장합니다.
구버전의 Discourse 인스턴스를 업그레이드하는 과정에서 이 문제를 경험하신 것으로 보입니다.
따라서 yml 파일을 수동으로 편집하여 Discourse를 "stable"로 사용하고 Postgres 버전을 12로 고정하여 Discourse의 복사본을 설치해 보세요.
빌드가 성공하면 백업 복원을 시도해 보세요. Hopefully, it will restore successfully.
성공하면 Postgres 12 템플릿을 기본 Postgres 템플릿으로 되돌리고 stable 태그를 주석 처리하여 Discourse가 최신 tests-passed 버전으로 다시 빌드되도록 하세요.
백업이 복구 가능한 상태라면, Postgres와 Discourse 업그레이드를 무사히 통과할 수 있을 것입니다.
지금 저는 사실상 “리밍보(limbo)” 상태입니다. PG12와 “Stable” 버전으로 제안하신 방법을 시도해 보았지만, 작동하지 않으며 복원 과정이 그냥 멈춰 버립니다. 그래서 이제 앱 재빌드도 되지 않는 상황이 되어, 처음부터 다시 시도하기 위해 머신을 다시 초기화하고 있습니다.
해당 머신이 “PG12로 되돌아가는” 작업을 하는 동안, 다른 머신에서는 앞으로 나아갈 수 있는지 확인해 보고 있습니다. 새 설치로 PG를 업그레이드하려고 하면 Creating missing functions in the discourse_functions schema... 단계에서 죽어버리고(500 오류를 반환하기 시작하며), tail -f shared/data/log/var-log/postgres/current를 확인해 보면 데이터 컨테이너가 "동작 중"인 것처럼 보이지만, 실제로는 다음과 같은 "오류"로 가득 차 있습니다:
discourse@discourse ERROR: relation "user_auth_tokens" does not exist at character 34
discourse@discourse STATEMENT: SELECT "user_auth_tokens".* FROM "user_auth_tokens" WHERE ((auth_token = 'XXXX=' OR
prev_auth_token = 'XXXX=') AND rotated_at > '2022-03-09 10:21:44.051357') LIMIT 1
discourse@discourse ERROR: relation "application_requests" does not exist at character 41
discourse@discourse STATEMENT: SELECT "application_requests"."id" FROM "application_requests" WHERE "application_requests"."date" = '2022-05-08' AND "application_requests"."req_type" = 0 LIMIT 1
하지만 Discourse는 죽어 있을지 몰라도 머신은 사용 중이므로… 작동은 하고 있지만 그냥 몇 시간씩 걸리는 건가요? 1시간 넘게 방任해 두었는데 아무런 변화가 없었거든요.