깨끗한 개발용 Docker 환경에서 백업 복원 실패: FATAL: Peer authentication failed for user “postgres”

초보자를 위한 Docker를 사용한 Discourse 개발용 설치 가이드(the beginners guide to install discourse for development using docker)에서 몇몇 댓글이 이 문제를 언급하고 있는데, 이것은 실제로 여기에서 이슈로 등록되어야 할 버그라고 생각합니다. 틀린 부분이 있다면 지적해 주세요.

저는 주요 설정 변경 사항을 테스트하기 위해 프로덕션 환경을 복사하는 방식을 주로 사용하며, 이전에 여러 번 이렇게 클린 슬레이트(clean slate)를 만들어 본 경험이 있습니다. 하지만 지금은 이 오류로 인해 백업이 실패하고 있습니다. 오류 내용은 피어 인증(peer authentication) 실패와 관련되어 있습니다.

제가 무엇을 하고 있는지(혹은 잘못하고 있는지) 맥락을 제공하기 위해 아래에 절차를 정리했습니다.

  1. 로컬 discourse 디렉토리를 완전히 삭제합니다.
  2. 모든 컨테이너를 중지하고 제거합니다.
  3. 새로 git clone으로 discourse를 가져오고, 바로 그 다음에 plugins 디렉토리에서 제가 사용하는 플러그인도 함께 가져옵니다.
  4. boot_dev --init 명령어들을 실행하고, 필요하면 bundle install을 수행하며, 필요하면 데이터베이스 마이그레이션을 진행합니다.
  5. 더미 관리자 계정으로 로그인하여 라이브 사이트에서 다운로드한 백업 파일을 업로드합니다.
  6. 백업 복원(restore backup)을 실행합니다.

추가로 제공할 정보가 있다면 알려주세요. 백업 로그는 아래와 같습니다. 그리고 아, data/postgres/의 pg_hba.conf 파일에서 모든 인증 방법이 "trust"로 설정되어 있는지 확인했습니다.

[2021-11-03 20:55:35] 'koen' has started the restore!
[2021-11-03 20:55:35] Marking restore as running...
[2021-11-03 20:55:35] Making sure /src/tmp/restores/default/2021-11-03-205535 exists...
[2021-11-03 20:55:35] Copying archive to tmp directory...
[2021-11-03 20:55:35] Extracting dump file...
[2021-11-03 20:55:36] Validating metadata...
[2021-11-03 20:55:36]   Current version: 20211022154420
[2021-11-03 20:55:36]   Restored version: 20211022154420
[2021-11-03 20:55:36] Enabling readonly mode...
[2021-11-03 20:55:36] Pausing sidekiq...
[2021-11-03 20:55:36] Waiting up to 60 seconds for Sidekiq to finish running jobs...
[2021-11-03 20:55:42] Creating missing functions in the discourse_functions schema...
[2021-11-03 20:55:42] Restoring dump file... (this may take a while)
[2021-11-03 20:55:42] psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2021-11-03 20:55:42] EXCEPTION: psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2021-11-03 20:55:42] /src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/src/lib/backup_restore/database_restorer.rb:26:in `restore'
/src/lib/backup_restore/restorer.rb:51:in `run'
/src/script/spawn_backup_restore.rb:23:in `restore'
/src/script/spawn_backup_restore.rb:36:in `block in <main>'
/src/script/spawn_backup_restore.rb:4:in `fork'
/src/script/spawn_backup_restore.rb:4:in `<main>'
[2021-11-03 20:55:42] Trying to rollback...
[2021-11-03 20:55:42] There was no need to rollback
[2021-11-03 20:55:42] Cleaning stuff up...
[2021-11-03 20:55:42] Dropping functions from the discourse_functions schema...
[2021-11-03 20:55:42] Removing tmp '/src/tmp/restores/default/2021-11-03-205535' directory...
[2021-11-03 20:55:42] Unpausing sidekiq...
[2021-11-03 20:55:42] Marking restore as finished...
[2021-11-03 20:55:42] Notifying 'koen' of the end of the restore...
[2021-11-03 20:55:46] Finished!
1개의 좋아요

여러분 안녕하세요, 이게 버그로 분류되는 건지, 그렇게 접수될 수 있는지 궁금합니다. 다른 방식으로 작성하거나 더 많은 정보를 추가해야 할까요? 다음 단계가 무엇인지만 궁금한 거고, 해결 시점에 대해서는 전혀 촉구하고 있지 않습니다.

안녕하세요 여러분, 몇 주가 지난 후 다시 한번 시도해 보기로 했습니다. 그래서 처음부터 다시 시작(cleanslate)하여 로컬 머신에 새로운 개발 환경을 설정하고 로그인했습니다. 그런 다음 프로덕션 환경과 일치하도록 플러그인을 추가했습니다. 라이브 사이트에서 백업을 가져와서 DTA 환경에 복원하려고 시도했습니다. 하지만 아쉽게도 여전히 동일한 오류가 발생합니다.

누군가 이 문제를 재현해 볼 수 있을까요? 예전에는 네이티브 개발 환경을 실행한 적이 있지만, docker 설정의 사용 편의성을 알게 된 후 그 환경을 제거했습니다. 이전 환경의 어떤 부분이 문제를 일으키고 있는 걸까요? 이전 로컬 postgres 데이터베이스 플랫폼에서 비롯된 오류일까요? cleanslate가 docker에서 실행되는 경우에도 서로 영향을 줄 수 있을까요? 그저 추측일 뿐입니다. 올바른 방향이나 도움을 줄 수 있는 사람을 알려주실 수 있나요? 테스트 목적으로 라이브 사이트의 사본을 가져오는 것은 꽤 중요한 사용 사례라고 생각합니다. 더 많은 정보를 제공하기 위해 제가 할 수 있는 일이 있을까요? 지금 자동 테스트를 실행하고 있지만, 이것도 아무것도 나오지 않습니다…

[2021-11-29 19:43:39] 'koen'이 복원을 시작했습니다!
[2021-11-29 19:43:39] 복원을 실행 중으로 표시하는 중...
[2021-11-29 19:43:39] /src/tmp/restores/default/2021-11-29-194339 디렉터리가 존재하는지 확인하는 중...
[2021-11-29 19:43:39] 아카이브를 tmp 디렉터리로 복사하는 중...
[2021-11-29 19:43:39] 덤프 파일 추출하는 중...
[2021-11-29 19:43:40] 메타데이터 검증하는 중...
[2021-11-29 19:43:40]   현재 버전: 20211124161346
[2021-11-29 19:43:40]   복원된 버전: 20211123033311
[2021-11-29 19:43:40] 읽기 전용 모드 활성화하는 중...
[2021-11-29 19:43:40] sidekiq 일시 중지하는 중...
[2021-11-29 19:43:40] Sidekiq이 작업 완료를 위해 최대 60초 대기 중...
[2021-11-29 19:43:46] discourse_functions 스키마에서 누락된 함수를 생성하는 중...
[2021-11-29 19:43:46] 덤프 파일 복원하는 중... (이 작업에는 시간이 걸릴 수 있습니다)
[2021-11-29 19:43:47] psql: 오류: 소켓 "/var/run/postgresql/.s.PGSQL.5432"에 대한 서버 연결 실패: FATAL:  "postgres" 사용자의 Peer 인증 실패
[2021-11-29 19:43:47] 예외: psql 실패: psql: 오류: 소켓 "/var/run/postgresql/.s.PGSQL.5432"에 대한 서버 연결 실패: FATAL:  "postgres" 사용자의 Peer 인증 실패

[2021-11-29 19:43:47] /src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/src/lib/backup_restore/database_restorer.rb:26:in `restore'
/src/lib/backup_restore/restorer.rb:51:in `run'
/src/script/spawn_backup_restore.rb:23:in `restore'
/src/script/spawn_backup_restore.rb:36:in `block in <main>'
/src/script/spawn_backup_restore.rb:4:in `fork'
/src/script/spawn_backup_restore.rb:4:in `<main>'
[2021-11-29 19:43:47] 롤백 시도 중...
[2021-11-29 19:43:47] 롤백할 필요가 없었습니다
[2021-11-29 19:43:47] 정리하는 중...
[2021-11-29 19:43:47] discourse_functions 스키마에서 함수를 삭제하는 중...
[2021-11-29 19:43:47] tmp '/src/tmp/restores/default/2021-11-29-194339' 디렉터리 제거하는 중...
[2021-11-29 19:43:47] sidekiq 일시 중지 해제하는 중...
[2021-11-29 19:43:47] 복원을 완료로 표시하는 중...
[2021-11-29 19:43:47] 'koen'에게 복원 종료 알림을 보내는 중...
[2021-11-29 19:43:51] 완료!

Koen

음, d/rake autospec를 실행하니 14개의 실패가 발생했는데, 그중 첫 6개는 PEER 인증 문제와 관련이 있는 것 같습니다.

정확히 파악이 안 되지만, 누군가가 조사할 수 있도록 여기에 공유해 둡니다. 매번 다른 Postgres 버전에서 동일한 오류가 나는 것 같습니다.

도움이 되길 바랍니다

Failures:

  1) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 9.5
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:61:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'

  2) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 9.3
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:51:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'

  3) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 12
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:74:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'

  4) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 11
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:70:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'

  5) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 9.5.5
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:56:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'

  6) BackupRestore::DatabaseRestorer#restore with real psql restores from PostgreSQL 10
     Failure/Error: raise DatabaseRestoreError.new("psql failed: #{last_line}") if Process.last_status&.exitstatus != 0
     
     BackupRestore::DatabaseRestoreError:
       psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"                                                                                        
     # ./lib/backup_restore/database_restorer.rb:92:in `restore_dump'
     # ./lib/backup_restore/database_restorer.rb:26:in `restore'
     # ./spec/lib/backup_restore/shared_context_for_backup_restore.rb:59:in `execute_stubbed_restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:41:in `restore'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:45:in `expect_restore_to_work'
     # ./spec/lib/backup_restore/database_restorer_spec.rb:66:in `block (4 levels) in <main>'
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'


저도 같은 상황입니다. UI와 터미널 모두에서 발생합니다.

아래에 전체 출력을 첨부합니다. 이는 Windows의 WSL2에서 실행 중인 것입니다.

혹시 아이디어가 있으신가요?

$ d/discourse restore ragdoll-forums-2022-03-27-000005-v20220215015538.tar.gz
Starting restore: ragdoll-forums-2022-03-27-000005-v20220215015538.tar.gz
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /src/tmp/restores/default/2022-03-28-104731 exists...
Copying archive to tmp directory...
Unzipping archive, this may take a while...
Extracting dump file...
Validating metadata...
  Current version: 20220325064954
  Restored version: 20220215015538
Enabling readonly mode...
Pausing sidekiq...
Waiting up to 60 seconds for Sidekiq to finish running jobs...
Creating missing functions in the discourse_functions schema...
Restoring dump file... (this may take a while)
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
EXCEPTION: psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
/src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/src/lib/backup_restore/database_restorer.rb:26:in `restore'
/src/lib/backup_restore/restorer.rb:51:in `run'
script/discourse:149:in `restore'
/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
script/discourse:290:in `<main>'
Trying to rollback...
There was no need to rollback
Cleaning stuff up...
Dropping functions from the discourse_functions schema...
Removing tmp '/src/tmp/restores/default/2022-03-28-104731' directory...
Unpausing sidekiq...
Marking restore as finished...
Notifying 'system' of the end of the restore...
Finished!
[FAILED]
Restore done.
Failed to report error: can't alloc thread 0   PostSearchData Upsert (1.1ms)  INSERT INTO "post_search_data" ("raw_data","post_id","locale","version","search_data","private_message") VALUES ('The restore has failed. Here’s the log: [2022-03-28 10:47:31] [STARTED] [2022-03-28 10:47:31] ''system'' has started the restore! [2022-03-28 10:47:31] Marking restore as running... [2022-03-28 10:47:31] Making sure /src/tmp/restores/default/2022-03-28-104731 exists... [2022-03-28 10:47:31] Copying archive to tmp directory... [2022-03-28 10:47:31] Unzipping archive, this may take a while... [2022-03-28 10:47:31] Extracting dump file... [2022-03-28 10:47:32] Validating metadata... [2022-03-28 10:47:32] Current version: 20220325064954 [2022-03-28 10:47:32] Restored version: 20220215015538 [2022-03-28 10:47:32] Enabling readonly mode... [2022-03-28 10:47:32] Pausing sidekiq... [2022-03-28 10:47:32] Waiting up to 60 seconds for Sidekiq to finish running jobs... [2022-03-28 10:47:38] Creating missing functions in the discourse_functions schema... [2022-03-28 10:47:38] Restoring dump file... (this may take a while) [2022-03-28 10:47:38] psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL : Peer authentication failed for user "postgres" [2022-03-28 10:47:38] EXCEPTION: psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres" [2022-03-28 10:47:38] /src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'' /src/lib/backup_restore/database_restorer.rb:26:in `restore'' /src/lib/backup_restore/restorer.rb:51:in `run'' script/discourse:149:in `restore'' /usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'' /usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'' /usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'' /usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'' script/discourse:290:in ` < main > '' [2022-03-28 10:47:38] Trying to rollback... [2022-03-28 10:47:38] There was no need to rollback [2022-03-28 10:47:38] Cleaning stuff up... [2022-03-28 10:47:38] Dropping functions from the discourse_functions schema... [2022-03-28 10:47:38] Removing tmp ''/src/tmp/restores/default/2022-03-28-104731'' directory... [2022-03-28 10:47:38] Unpausing sidekiq... [2022-03-28 10:47:38] Marking restore as finished... [2022-03-28 10:47:38] Notifying ''system'' of the end of the restore...', 17, 'en', 4, '''-03'':12,19,30,40,50,61,74,83,91,100,109,118,126,143,157,171,193,218,262,271,283,292,305,315,323,333 ''-28'':13,20,31,41,51,62,75,84,92,101,110,119,127,144,158,172,194,219,263,272,284,293,306,316,324,334 ''/src/lib/backup_restore/database_restorer.rb'':223,228 ''/src/lib/backup_restore/restorer.rb'':232 ''/src/tmp/restores/default/2022-03-28-104731'':47,312 ''/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb'':249 ''/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/base.rb'':253 ''/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb'':240 ''/usr/local/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb'':244 ''/var/run/postgresql/.s.pgsql.5432'':183,208 ''10'':14,21,32,42,52,63,76,85,93,102,111,120,128,145,159,173,195,220,264,273,285,294,307,317,325,335 ''127'':245 ''149'':237 ''2022'':11,18,29,39,49,60,73,82,90,99,108,117,125,142,156,170,192,217,261,270,282,291,304,314,322,332 ''20220215015538'':107 ''20220325064954'':98 ''26'':229 ''27'':241 ''290'':258 ''31'':16,23,34,44,54,65,78 ''32'':87,95,104,113,122,130 ''38'':147,161,175,197,222,266,275,287,296,309,319,327,337 ''392'':250 ''47'':15,22,33,43,53,64,77,86,94,103,112,121,129,146,160,174,196,221,265,274,286,295,308,318,326,336 ''485'':254 ''51'':233 ''60'':134 ''92'':224 ''archiv'':56,67 ''authent'':187,212 ''clean'':288 ''command'':248 ''connect'':178,203 ''copi'':55 ''creat'':148 ''current'':96 ''directori'':59,313 ''discours'':153,301 ''dispatch'':252 ''drop'':297 ''dump'':80,163,227 ''enabl'':114 ''end'':342 ''error'':177,202 ''except'':198 ''exist'':48 ''extract'':79 ''fail'':2A,6,184,188,200,209,213 ''fatal'':185,210 ''file'':81,164 ''finish'':139,331 ''function'':150,154,298,302 ''invok'':247 ''job'':141 ''log'':10 ''main'':260 ''make'':45 ''mark'':35,328 ''may'':69,166 ''metadata'':89 ''miss'':149 ''mode'':116 ''need'':279 ''notifi'':338 ''paus'':123 ''peer'':186,211 ''postgr'':191,216 ''psql'':176,199,201 ''readon'':115 ''remov'':310 ''restor'':1A,4,28,36,105,162,226,231,239,329,345 ''rollback'':269,281 ''run'':38,140,235,243 ''schema'':155,303 ''script/discourse'':236,257 ''second'':135 ''server'':180,205 ''sidekiq'':124,137,321 ''socket'':182,207 ''start'':17,26,256 ''stuff'':289 ''sure'':46 ''system'':24,339 ''take'':70,167 ''tmp'':58,311 ''tri'':267 ''unpaus'':320 ''unzip'':66 ''user'':190,215 ''valid'':88 ''version'':97,106 ''wait'':131 ', TRUE) ON CONFLICT ("post_id") DO UPDATE SET "raw_data"=excluded."raw_data","locale"=excluded."locale","version"=excluded."version","search_data"=excluded."search_data","private_message"=excluded."private_message" RETURNING "post_id"
1개의 좋아요

저도 같은 문제를 겪었습니다.
결국 임시 조치로 다음 코드를 삽입했습니다.

   if Rails.env.development?
      username = "discourse"
      password = "discourse"
      config["host"] = "localhost"
      config["port"] = 5432
      config["database"] = "discourse_development"
    end

이 코드를 DatabaseConfiguration.new(

  DatabaseConfiguration.new(

이전에 /lib/backup_restore.rb 파일에 넣었습니다.

또한 discourse 사용자의 비밀번호를 설정해야 했습니다.

d/psql -c "ALTER USER discourse WITH PASSWORD 'discourse';"

이보다 더 나은 방법이 있을 수도 있습니다.

1개의 좋아요

정말 감사합니다! 큰 도움이 되었습니다! :slight_smile:

개인적 의견으로는 #contribute:bug로 처리하는 것이 적절할 것 같습니다.

프로덕션 사이트에는 영향을 주지 않으므로 우선순위가 낮은 버그입니다. 그리고 현재 팀에서 Docker 환경을 개발에 사용하는 사람은 없는 것 같습니다. 해당 주제를 재분류하고 pr-welcome 태그를 붙였습니다.

5개의 좋아요

저는 이렇게 해결했습니다:

하지만 이 문제를 해결하기 위한 다른 방법들도 몇 가지 있습니다:

  • docker 부트 이미지에서 환경 변수 설정 USER=discourse를 추가합니다

  • d\exec에 -e USER=discourse \를 추가합니다

  • backup_restore.rb에 다음 내용을 추가합니다

      if Rails.env.development?
        username = ENV["USER"] || "discourse"
      end
    

또한, docker 개발 환경에서 d/discourse를 실행할 때 새로운 문제가 발생합니다:

$ d/discourse backup
<internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require': cannot load such file -- thor (LoadError)
        from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
        from script/discourse:4:in `<main>'

반면 d/bundle exec script/discourse backup은 정상적으로 작동합니다 (관련 패치 참고).

안녕하세요 @gerhard,

이 주제에서 언급된 동일한 문제를 겪었고, 위의 PR이 제 문제를 해결해 주었습니다. 이 PR을 다시 열어 병합해야 한다고 생각합니다.

1개의 좋아요

PR이 이상적이지 않습니다. 명시적으로 정의된 경우에만 사용자를 추가하려는 것인데, 모든 개발 환경에 discourse 사용자를 강제하는 것은 적절하지 않습니다.

해당 환경 변수가 정의된 경우 선택적으로 처리하는 방식에는 동의합니다.

2개의 좋아요

저는 dev docker 환경을 사용하지 않아서 테스트를 할 수 없지만, 이렇게 하면 될지도 모르겠네요?

--- a/lib/backup_restore.rb
+++ b/lib/backup_restore.rb
@@ -135,7 +135,8 @@ module BackupRestore
     DatabaseConfiguration.new(
       config["backup_host"] || config["host"],
       config["backup_port"] || config["port"],
-      config["username"] || username || ENV["USER"] || "postgres",
+      config["username"] || username || ENV["USER"] || ENV["DISCOURSE_DEV_DB_USERNAME"] ||
+        "postgres",
       config["password"] || password,
       config["database"],
     )

이렇게 되면 PR을 만들어 주세요.

1개의 좋아요

dev container 방식을 사용하는 경우, “remoteEnv” 섹션에 “USER”: "discourse"만 추가하면 작동하며 DB를 내보낼 수 있습니다.

1개의 좋아요

이 의견에 동의합니다. 제 devcontainer 인스턴스에서 이 항목을 추가한 후에야 백업과 복원이 가능했습니다. @sreenu_paruchuri 님 감사합니다.

   "remoteEnv": {
     "RAILS_DEVELOPMENT_HOSTS": ".app.github.dev",
+    "USER": "discourse",
     "PGUSER": "discourse",
     "SELENIUM_FORWARD_DEVTOOLS_TO_PORT": "9229",
   },
3개의 좋아요