키 (plugin_name, key)=(discourse-data-explorer, q:-1)가 중복되어 복원 실패

Discourse를 업그레이드한 후 작동하지 않는 것을 발견했습니다. 카테고리 페이지는 볼 수 있지만, 최신 게시글이나 인기 게시글 페이지(예: 최신 페이지)를 읽을 수 없습니다.

이미 공식 및 비공식 플러그인을 포함한 모든 플러그인을 삭제했지만 문제가 여전히 존재합니다.

그래서 백업을 복원해 보았지만, 다음과 같은 메시지를 발견했습니다.

[2020-07-12 01:16:20] ERROR:  could not create unique index "index_plugin_store_rows_on_plugin_name_and_key"
[2020-07-12 01:16:20] DETAIL:  Key (plugin_name, key)=(discourse-data-explorer, q:-1) is duplicated.
[2020-07-12 01:16:20] EXCEPTION: psql failed: DETAIL:  Key (plugin_name, key)=(discourse-data-explorer, q:-1) is duplicated.

[2020-07-12 01:16:20] /var/www/discourse/lib/backup_restore/database_restorer.rb:95:in `restore_dump'
/var/www/discourse/lib/backup_restore/database_restorer.rb:26:in `restore'
/var/www/discourse/lib/backup_restore/restorer.rb:49:in `run'
/var/www/discourse/lib/backup_restore.rb:188:in `block in start!'

플러그인 스토어에 손상된 데이터가 있습니다.

데이터 탐색기에 저장한 사용자 지정 데이터에 대해 신경 쓰지 않으시다면 다음을 시도해 보세요:

./launcher enter app
rails c
PluginStore.where(plugin_name: 'discourse-data-explorer').delete_all
root@HFT-app:/var/www/discourse# rails c
[1] pry(main)> PluginStore.where(plugin_name: 'discourse-data-explorer').delete_all
NoMethodError: undefined method `where' for PluginStore:Class
Did you mean?  when
from (pry):1:in `__pry__'
[2] pry(main)>


뭔가 문제가 있는 것 같습니다.

추가로 정보를 알려주실 수 있나요?

PluginStoreRow여야 하며, PluginStore가 아닙니다. 다음을 시도해 보세요:

./launcher enter app
rails c
PluginStoreRow.where(plugin_name: 'discourse-data-explorer').delete_all

:warning: 이 작업은 사이트에서 모든 data-explorer 데이터를 되돌릴 수 없이 삭제합니다

그렇다면 제가 뭘 해야 할까요?
포럼이 이제 읽을 수 없네요. latest.json 파일이 사라진 것 같습니다.

앱을 다시 빌드해 보겠습니다. 그래도 안 되면 /logs에서 오류를 확인해 보세요.

로그를 확인하는 방법은?

재빌드 과정의 로그를 말씀하시는 거라면, 재빌드 시 발생하는 오류 메시지는 다음과 같습니다(모든 빨간색 단어는 여기 있습니다).


2020/07/14 11:33:39 socat[26] E connect(6, AF=1 "/shared/postgres_run/.s.PGSQL.5432", 36): No such file or directory


#------




2020-07-14 11:33:42.023 UTC [49] LOG:  database system is ready to accept connections
I, [2020-07-14T11:33:46.972466 #1]  INFO -- :
I, [2020-07-14T11:33:46.972792 #1]  INFO -- : > su postgres -c 'createdb discourse' || true
2020-07-14 11:33:47.025 UTC [62] postgres@postgres ERROR:  database "discourse" already exists
2020-07-14 11:33:47.025 UTC [62] postgres@postgres STATEMENT:  CREATE DATABASE discourse;
createdb: error: database creation failed: ERROR:  database "discourse" already exists
I, [2020-07-14T11:33:47.026573 #1]  INFO -- :
I, [2020-07-14T11:33:47.026936 #1]  INFO -- : > su postgres -c 'psql discourse -c "create user discourse;"' || true
2020-07-14 11:33:47.083 UTC [73] postgres@discourse ERROR:  role "discourse" already exists
2020-07-14 11:33:47.083 UTC [73] postgres@discourse STATEMENT:  create user discourse;
ERROR:  role "discourse" already exists


안녕하세요, 코드를 실행하는 방법을 알려주실 수 있나요?

@xiasummer

현재 DB와 업로드 폴더에 대한 확인된 전체 백업이 있는 경우에만(IFF), 해당 백업을 공유 디렉터리에서 이동하거나 복사할 수 있습니다(예를 들어, 아래처럼 하되 구성에 맞게 조정하세요):

mv  /var/discourse/shared  /tmp

물론 먼저 DB의 전체 백업이 있는지 확인하세요.

그런 다음 처음부터 다시 빌드할 수 있습니다:

./launcher rebuild app

그리고 나서 명령줄을 통해 복원할 수 있습니다:

cp -rf /tmp/shared/backups/default /var/discourse/shared/standalone/backups

그 후 최신 백업을 사용하여 일반적인 방식으로 명령줄에서 복원을 수행할 수 있습니다.

이 과정을 통해 애플리케이션 백업이 마지막 정상적이고 완전한 백업 시점으로 복원됩니다.

이 방법은 전체 DB와 업로드 파일에 대한 최근의 전체 백업이 있는 경우에만 권장됩니다.

업로드를 제외한 백업을 수행한 경우, 업로드는 물론 /tmp/shared/standalone/uploads에서 찾을 수 있으며, 다음과 같이 복사할 수 있습니다:

cp -rf /tmp/shared/standalone/uploads/* /var/discourse/shared/standalone/uploads

모든 것이 다시 정상적으로 작동하고, 복원이 기대했던 대로 잘 진행되었는지 확신이 들면, 물론 스테이징 디렉터리를 삭제할 수 있습니다:

rm -rf /tmp/shared

진행할 수 있는 방법 중 하나입니다.

다른 방법도 있을 수 있지만, 최신이고 상태가 좋은 전체 백업이 있다면 저라면 이렇게 진행할 것입니다.