도와주세요! 업그레이드 후 완전히 실패했습니다

안녕하세요,

최근 업그레이드(6에서 7로)를 실행했을 때, 중복된 사용자 이름이라는 이유로 rake db:migrate가 실패했습니다. 저는 리눅스 커맨드라인에 익숙하지 않아서 문제를 해결하기 위해 Rails 콘솔을 입력해 보았지만, 데이터베이스에 연결할 수 없어 콘솔이 로드되지 않았습니다. 그 후 구글링을 통해 /etc/init.d/postgresql restart를 시도해 보았으나 다음 오류와 함께 실패했습니다:

[....] Restarting PostgreSQL 12 database server: main[....] 
Error: /usr/lib/postgresql/12/bin/pg_ctl /usr/lib/postgresql/12/bin/pg_ctl start -D /shared/postgres_data -l /var/log/postgresql/postgresql-12-main.log -s -o -c config_file="/etc/postgresql/12/main/postgresql.conf" exited with status 1: 2021-03-08 20:19:10.354 UTC [763] 
FATAL: database files are incompatible with server 2021-03-08 20:19:10.354 UTC [763] 
DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 12.3 (Debian 12.3-1.pgdg100+1). p[FAIL: could not start server Examine the log output. ... failed!
 failed!

그 다음 /etc/init.d/postgresql restart version 12.3을 시도해 보았지만, 오류 메시지는 없었지만 다른 메시지도 나오지 않았습니다. 그리고 여전히 psql에 로그인할 수 없습니다(최소한 이 포럼에서 찾은 sudo -u postgres psql discourse 명령을 사용하는 경우).

누군가 서버를 복구하는 방법에 대해 조언해 주실 수 있을까요? 그리고 왜 최신 업그레이드가这么大的 오류를 일으킨 것일까요? 저는 30분 설치 방법을 사용했고, 모든 것이 최대한 표준 설정 그대로입니다. 이 문제를 해결해 주시는 분께 비용을 지불할 의향도 있습니다.

@pfaffman 님은 이 같은 지원에 전문적이니, 그분에게 연락해 보시는 것이 좋겠습니다.

정확한 실패 로그를 가지고 계신가요? 조금 스크롤을 내려보실 필요가 있을 수 있지만, 저는 다음 사항에 대해 궁금합니다.

  1. 실패한 마이그레이션의 이름
  2. 실패를 유발한 문장

어딘가에 존재하던 버그로 인해 대소문자가 다른 사용자 이름이 허용되고 있었습니다. 이후 수정되어 더 이상 그런 일이 일어나지 않도록 했습니다.

기존 컨테이너를 다시 실행하고 UX를 통해 수정할 수 있을지도 모릅니다.

하지만 최근에 커맨드 라인 업그레이드를 하지 않았다면, 데이터베이스 업그레이드도 추가로 필요하므로 상황이 더 복잡해질 수 있습니다.

상황이 그보다 훨씬 나쁘지 않다면, 내일 오전(태평양 시간)에 직접 수정하겠습니다. Redirecting…

오늘 밤 안에 해결을 원하신다면 더 많은 비용을 지불할 수 있습니다. 그렇다면 서둘러 Jay@literatecomputing.com으로 이메일을 보내주세요. 최소한 서비스는 다시 복구할 수 있을지도 모릅니다.

웹 인터페이스에서 나온 출력입니다:

*** 잠시 기다려 주세요. 다음 단계에 시간이 좀 걸릴 수 있습니다 ***
********************************************************
메모리를 확보하기 위해 Cycling Unicorn 실행 중
Unicorn 재시작 중 pid: 46
Unicorn이 다시 로드될 때까지 대기 중.
Unicorn이 다시 로드될 때까지 대기 중..
Unicorn이 다시 로드될 때까지 대기 중...
Unicorn이 다시 로드될 때까지 대기 중....
Unicorn이 다시 로드될 때까지 대기 중.....
Unicorn이 다시 로드될 때까지 대기 중......
Unicorn이 다시 로드될 때까지 대기 중.......
Unicorn이 다시 로드될 때까지 대기 중........
Unicorn이 다시 로드될 때까지 대기 중.........
Unicorn이 다시 로드될 때까지 대기 중..........
Unicorn이 다시 로드될 때까지 대기 중...........
Unicorn이 다시 로드될 때까지 대기 중............
메모리를 확보하기 위해 3개의 Unicorn 워커를 중지합니다
메모리를 확보하기 위해 작업 큐를 중지합니다. 마스터 pid는 10397입니다
$ cd /var/www/discourse && git fetch --tags --force && git reset --hard HEAD@{upstream}
From https://github.com/discourse/discourse
 t [tag update]            latest-release -> latest-release
 * [new tag]               v2.5.6         -> v2.5.6
Checking out files:  87% (2225/2539)  
Checking out files:  88% (2235/2539)  
Checking out files:  89% (2260/2539)  
Checking out files:  90% (2286/2539)  
Checking out files:  91% (2311/2539)  
Checking out files:  92% (2336/2539)  
Checking out files:  93% (2362/2539)  
Checking out files:  94% (2387/2539)  
Checking out files:  95% (2413/2539)  
Checking out files:  96% (2438/2539)  
Checking out files:  97% (2463/2539)  
Checking out files:  98% (2489/2539)  
Checking out files:  99% (2514/2539)  
Checking out files: 100% (2539/2539)  
Checking out files: 100% (2539/2539), done.
HEAD is now at 0da649e4fa DEV: add new plugin outlet to tags template (#12302)
$ bundle install --deployment --jobs 4 --without test development
[DEPRECATED] `--deployment` 플래그는 더 이상 사용되지 않습니다. bundler 호출 간에 기억되도록 의존하기 때문이며, 향후 버전에서는 bundler가 더 이상 이를 수행하지 않습니다. 대신 `bundle config set deployment 'true'`를 사용하고 이 플래그 사용을 중단하세요.
[DEPRECATED] `--without` 플래그는 더 이상 사용되지 않습니다. bundler 호출 간에 기억되도록 의존하기 때문이며, 향후 버전에서는 bundler가 더 이상 이를 수행하지 않습니다. 대신 `bundle config set without 'test development'`를 사용하고 이 플래그 사용을 중단하세요.
Warning: 실행 중인 Bundler 버전(2.1.4)이 lockfile을 생성한 버전(2.2.7)보다 오래되었습니다. lockfile을 생성한 버전으로 업그레이드하는 것이 좋습니다. `gem install bundler:2.2.7`을 실행하여 업그레이드하세요.
Fetching gem metadata from https://rubygems.org/............
Fetching https://github.com/discourse/mail.git
Fetching rake 13.0.3
Installing rake 13.0.3
Fetching concurrent-ruby 1.1.8
Fetching minitest 5.14.4
Using thread_safe 0.3.6
Fetching zeitwerk 2.4.2
Installing zeitwerk 2.4.2
Installing minitest 5.14.4
Installing concurrent-ruby 1.1.8
Using builder 3.2.4
Using erubi 1.10.0
Fetching racc 1.5.2
Using crass 1.0.6
Using rack 2.2.3
Using mini_mime 1.0.2
Using public_suffix 4.0.6
Fetching aws-eventstream 1.1.1
Installing racc 1.5.2 with native extensions
Installing aws-eventstream 1.1.1
Using aws-partitions 1.390.0
Using jmespath 1.4.0
Using ember-source 2.18.2
Using execjs 2.7.0
Fetching msgpack 1.4.2
Installing msgpack 1.4.2 with native extensions
Using bundler 2.1.4
Using byebug 11.1.3
Using cbor 0.5.9.6
Fetching chunky_png 1.4.0
Installing chunky_png 1.4.0
Using coderay 1.1.3
Using colored2 3.1.2
Using connection_pool 2.2.3
Using cppjieba_rb 0.3.3
Using diffy 3.4.0
Using method_source 1.0.0
Fetching openssl 2.2.0
Fetching thor 1.1.0
Using discourse-ember-source 3.12.2.2
Fetching discourse-fonts 0.0.7
Installing thor 1.1.0
Installing openssl 2.2.0 with native extensions
Using exifr 1.3.9
Using fspath 3.1.2
Using image_size 1.5.0
Using in_threads 1.5.4
Using progress 3.5.2
Using email_reply_trimmer 0.1.13
Fetching excon 0.79.0
Installing excon 0.79.0
Installing discourse-fonts 0.0.7
Using multipart-post 2.1.1
Fetching faraday-net_http 1.0.1
Fetching ruby2_keywords 0.0.4
Using fast_blank 1.0.0
Using fast_xs 0.8.0
Fetching fastimage 2.2.3
Installing ruby2_keywords 0.0.4
Installing faraday-net_http 1.0.1
Installing fastimage 2.2.3
Fetching ffi 1.15.0
Using gc_tracer 1.5.1
Using guess_html_encoding 0.0.11
Using hashie 4.1.0
Using highline 2.0.3
Using hkdf 0.3.0
Using htmlentities 4.3.4
Using http_accept_language 2.1.1
Fetching json 2.5.1
Using jwt 2.2.2
Using kgio 2.11.3
Using libv8 8.4.255.0 (x86_64-linux)
Using logstash-event 1.2.02
Fetching logster 2.9.6
Installing json 2.5.1 with native extensions
Installing logster 2.9.6
Installing ffi 1.15.0 with native extensions
Using lru_redux 1.1.0
Using lz4-ruby 0.3.3
Using maxminddb 0.1.22
Fetching memory_profiler 1.0.0
Installing memory_profiler 1.0.0
Using redis 4.2.5
Using multi_json 1.15.0
Using multi_xml 0.6.0
Using mustache 1.1.1
Fetching mini_sql 1.0.1
Fetching nio4r 2.5.7
Installing mini_sql 1.0.1
Installing nio4r 2.5.7 with native extensions
Fetching oauth 0.5.5
Fetching oj 3.11.2
Installing oauth 0.5.5
Installing oj 3.11.2 with native extensions
Using optimist 3.0.1
Using pg 1.2.3
Using r2 0.2.7
Using raindrops 0.19.1
Using rchardet 1.8.0
Using rinku 2.0.6
Using rotp 6.2.0
Fetching rqrcode_core 0.2.0
Using rtlit 0.0.5
Using rubyzip 2.3.0
Using tilt 2.0.10
Using sshkey 2.0.0
Using stackprof 0.2.16
Using unf_ext 0.0.7.7
Using xorcist 1.1.2
Installing rqrcode_core 0.2.0
Using rack-test 1.1.0
Using mail 2.8.0.edge from https://github.com/discourse/mail.git (at master@5b700fc)
Fetching tzinfo 1.2.9
Using addressable 2.7.0
Using request_store 1.5.0
Using message_bus 3.3.4
Fetching rack-mini-profiler 2.3.1
Using rack-protection 2.1.0
Using aws-sigv4 1.2.2
Using barber 0.12.2
Using ember-data-source 3.0.2
Using uglifier 4.2.0
Fetching i18n 1.8.9
Installing i18n 1.8.9
Installing tzinfo 1.2.9
Installing rack-mini-profiler 2.3.1
Using sprockets 3.7.2
Fetching bootsnap 1.7.2
Installing bootsnap 1.7.2 with native extensions
Using pry 0.13.1
Using discourse_image_optim 0.26.2
Fetching nokogiri 1.11.1 (x86_64-linux)
Fetching openssl-signature_algorithm 1.1.1
Fetching faraday 1.3.0
Installing openssl-signature_algorithm 1.1.1
Installing faraday 1.3.0
Using omniauth 1.9.1
Using logstash-logger 0.26.1
Using mini_racer 0.3.1
Using webpush 1.1.0
Fetching sidekiq 6.1.3
Installing sidekiq 6.1.3
Fetching redis-namespace 1.8.1
Installing nokogiri 1.11.1 (x86_64-linux)
Installing redis-namespace 1.8.1
Fetching mini_suffix 0.3.2
Installing mini_suffix 0.3.2
Using sassc 2.0.1
Using rbtrace 0.4.14
Fetching unicorn 5.8.0
Fetching puma 5.2.2
Installing unicorn 5.8.0 with native extensions
Installing puma 5.2.2 with native extensions
Using unf 0.1.4
Fetching rqrcode 1.2.0
Fetching css_parser 1.9.0
Using aws-sdk-core 3.109.2
Using ember-handlebars-template 0.8.0
Using pry-byebug 3.9.0
Using pry-rails 0.3.9
Fetching activesupport 6.0.3.5
Installing css_parser 1.9.0
Installing rqrcode 1.2.0
Installing activesupport 6.0.3.5
Using cose 1.2.0
Fetching omniauth-oauth 1.2.0
Installing omniauth-oauth 1.2.0
Using oauth2 1.4.4
Fetching mini_scheduler 0.13.0
Fetching loofah 2.9.0
Installing mini_scheduler 0.13.0
Installing loofah 2.9.0
Fetching nokogumbo 2.0.4
Using ruby-readability 0.7.0
Using aws-sdk-kms 1.39.0
Using aws-sdk-sns 1.35.0
Fetching omniauth-oauth2 1.7.1
Installing nokogumbo 2.0.4 with native extensions
Installing omniauth-oauth2 1.7.1
Using omniauth-twitter 1.4.0
Using rails-html-sanitizer 1.3.0
Using aws-sdk-s3 1.83.2
Using omniauth-facebook 8.0.0
Using omniauth-github 1.4.0
Fetching omniauth-google-oauth2 0.8.1
Installing omniauth-google-oauth2 0.8.1
Using rails-dom-testing 2.0.3
Using globalid 0.4.2
Fetching actionview 6.0.3.5
Fetching activemodel 6.0.3.5
Fetching activejob 6.0.3.5
Installing activejob 6.0.3.5
Installing activemodel 6.0.3.5
Installing actionview 6.0.3.5
Fetching sanitize 5.2.3
Installing sanitize 5.2.3
Using active_model_serializers 0.8.4
Fetching activerecord 6.0.3.5
Fetching onebox 2.2.6
Installing activerecord 6.0.3.5
Installing onebox 2.2.6
Fetching actionpack 6.0.3.5
Installing actionpack 6.0.3.5
Using actionview_precompiler 0.2.3
Fetching railties 6.0.3.5
Fetching actionmailer 6.0.3.5
Installing actionmailer 6.0.3.5
Installing railties 6.0.3.5
Using sprockets-rails 3.2.2
Using seed-fu 2.3.9
Using jquery-rails 4.4.0
Using lograge 0.11.2
Fetching rails_failover 0.6.5
Using rails_multisite 2.5.0
Using sassc-rails 2.1.2
Using discourse-ember-rails 0.18.6
Installing rails_failover 0.6.5
Bundle complete! 124 Gemfile dependencies, 162 gems now installed.
Gems in the groups test and development were not installed.
Bundled gems are installed into `./vendor/bundle`
$ bundle exec rake plugin:pull_compatible_all
discourse-legal-tools is already at latest compatible version
docker_manager is already at latest compatible version
$ SKIP_POST_DEPLOYMENT_MIGRATIONS=1 bundle exec rake multisite:migrate

--------------------------------------------------------------------------------
1 migrations failed!

Failed to migrate default
#<StandardError: An error has occurred, this and all later migrations canceled:

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_username"
DETAIL:  Key (username)=(Martina_S) already exists.
>
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.3.1/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-2.3.1/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:890:in `block in method_missing'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:858:in `block in say_with_time'
/usr/local/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:858:in `say_with_time'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:879:in `method_missing'
/var/www/discourse/db/migrate/20210120125607_rename_english_locale.rb:17:in `rename_locale'
/var/www/discourse/db/migrate/20210120125607_rename_english_locale.rb:6:in `up'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:831:in `exec_migration'
/var/www/discourse/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/usr/local/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
/var/www/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/usr/local/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:811:in `block in migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:810:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1002:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.5/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/transactions.rb:212:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1361:in `ddl_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1280:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1229:in `block in migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1229:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1061:in `up'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/migration.rb:1036:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.5/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/var/www/discourse/lib/tasks/db.rake:184:in `block (2 levels) in <main>'
/var/www/discourse/lib/tasks/db.rake:148:in `block (3 levels) in execute_concurently'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:76:in `with_connection'
/var/www/discourse/lib/tasks/db.rake:146:in `block (2 levels) in execute_concurently'

Multisite migrator is running using 1 threads

Migrating default
== 20201117212328 SetCategorySlugToLower: migrating ===========================
-- remove_index(:categories, {:name=>"unique_index_categories_on_slug"})
   -> 0.0069s
-- execute("UPDATE categories SET slug = LOWER(slug)")
   -> 0.0196s
-- add_index(:categories, "COALESCE(parent_category_id, -1), LOWER(slug)", {:name=>"unique_index_categories_on_slug", :where=>"slug != ''", :unique=>true})
   -> 0.0138s
== 20201117212328 SetCategorySlugToLower: migrated (0.0528s) ==================

== 20201210151635 CreateDoNotDisturbTimings: migrating ========================
-- create_table(:do_not_disturb_timings)
   -> 0.0192s
-- add_index(:do_not_disturb_timings, [:user_id], {:unique=>false})
   -> 0.0039s
-- add_index(:do_not_disturb_timings, [:starts_at], {:unique=>false})
   -> 0.0029s
-- add_index(:do_not_disturb_timings, [:ends_at], {:unique=>false})
   -> 0.0026s
== 20201210151635 CreateDoNotDisturbTimings: migrated (0.0296s) ===============

== 20201218000000 RemoveFlagWebHooks: migrating ===============================
-- execute("DELETE FROM web_hook_event_types_hooks\nWHERE web_hook_event_type_id = 7\n")
   -> 0.0005s
-- execute("DELETE FROM web_hook_event_types\nWHERE id = 7\n")
   -> 0.0004s
== 20201218000000 RemoveFlagWebHooks: migrated (0.0016s) ======================

== 20201218000001 RemoveQueuedPostWebHooks: migrating =========================
-- execute("DELETE FROM web_hook_event_types_hooks\nWHERE web_hook_event_type_id = 8\n")
   -> 0.0002s
-- execute("DELETE FROM web_hook_event_types\nWHERE id = 8\n")
   -> 0.0002s
== 20201218000001 RemoveQueuedPostWebHooks: migrated (0.0011s) ================

== 20201229031635 AddUserProfileIndexes: migrating ============================
-- execute("CREATE INDEX CONCURRENTLY IF NOT EXISTS index_topic_links_on_user_and_clicks\nON topic_links(user_id, clicks DESC, created_at DESC)\nWHERE (NOT reflection and NOT quote and NOT internal)\n")
   -> 0.2598s
-- execute("CREATE INDEX CONCURRENTLY IF NOT EXISTS index_posts_user_and_likes\nON posts(user_id, like_count desc, created_at desc)\nWHERE post_number > 1\n")
   -> 0.7620s
== 20201229031635 AddUserProfileIndexes: migrated (1.0231s) ===================

== 20210105165605 AddProcessedToNotifications: migrating ======================
== 20210105165605 AddProcessedToNotifications: migrated (0.0007s) =============

== 20210106181418 CreateUserNotificationSchedules: migrating ==================
-- create_table(:user_notification_schedules)
   -> 0.0043s
-- add_index(:user_notification_schedules, [:user_id])
   -> 0.0027s
-- add_index(:user_notification_schedules, [:enabled])
   -> 0.0024s
-- add_column(:do_not_disturb_timings, :scheduled, :boolean, {:default=>false})
   -> 0.0008s
-- add_index(:do_not_disturb_timings, [:scheduled])
   -> 0.0024s
== 20210106181418 CreateUserNotificationSchedules: migrated (0.0134s) =========

== 20210107005832 AddImapMissingColumnToIncomingEmail: migrating ==============
-- add_column(:incoming_emails, :imap_missing, :boolean, {:default=>false, :null=>false})
   -> 0.0013s
== 20210107005832 AddImapMissingColumnToIncomingEmail: migrated (0.0019s) =====

== 20210111025920 AddRejectReasonToReviewables: migrating =====================
-- add_column(:reviewables, :reject_reason, :text)
   -> 0.0008s
== 20210111025920 AddRejectReasonToReviewables: migrated (0.0015s) ============

== 20210119005647 AddCreatedViaToIncomingEmail: migrating =====================
-- add_column(:incoming_emails, :created_via, :integer, {:null=>true})
   -> 0.0006s
== 20210119005647 AddCreatedViaToIncomingEmail: migrated (0.0012s) ============

== 20210120125607 RenameEnglishLocale: migrating ==============================
-- execute("UPDATE users\nSET locale = 'en_GB'\nWHERE locale = 'en'\n")
   -> 0.0107s
-- execute("UPDATE site_settings\nSET value = 'en_GB'\nWHERE name = 'default_locale' AND value = 'en'\n")
   -> 0.0007s
-- execute("UPDATE translation_overrides\nSET locale = 'en_GB'\nWHERE locale = 'en'\n")
   -> 0.0004s
-- execute("UPDATE theme_translation_overrides\nSET locale = 'en_GB'\nWHERE locale = 'en'\n")
   -> 0.0005s
-- execute("UPDATE users\nSET locale = 'en'\nWHERE locale = 'en_US'\n")
Docker Manager: FAILED TO UPGRADE
#<RuntimeError: RuntimeError>
/var/www/discourse/plugins/docker_manager/lib/docker_manager/upgrader.rb:196:in `run'
/var/www/discourse/plugins/docker_manager/lib/docker_manager/upgrader.rb:100:in `upgrade'
/var/www/discourse/plugins/docker_manager/scripts/docker_manager_upgrade.rb:19:in `block in <main>'
/var/www/discourse/plugins/docker_manager/scripts/docker_manager_upgrade.rb:6:in `fork'
/var/www/discourse/plugins/docker_manager/scripts/docker_manager_upgrade.rb:6:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.3/lib/rails/commands/runner/runner_command.rb:42:in `perform'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.3/lib/rails/command/base.rb:69:in `perform'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.3/lib/rails/command.rb:46:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/railties-6.0.3.3/lib/rails/commands.rb:18:in `<main>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:291:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/dependencies.rb:324:in `require'
bin/rails:17:in `<main>'
Spinning up 3 Unicorn worker(s) that were stopped initially

그 후, 웹 인터페이스보다 더 견고할 것 같아서 SSH를 통해 업데이트를 실행했습니다. (2020년에는 몇 달 동안 웹 인터페이스가 어떤 것도 업데이트를 거부해서 항상 SSH를 통해 진행해야 했습니다.) 명령줄에 업데이트 명령을 입력하자 많은 양의 데이터를 다운로드한 끝에 rebuild app 명령을 실행하라고 알려주었습니다. 해당 명령을 실행하자 동일한 오류가 발생했습니다. 주변 줄이 동일했는지 확신할 수는 없지만 복사하지 않았으며, 데이터베이스 마이그레이션 중간에 분명히 이 index_username_on_users 문제가 있었습니다.

TL;DR: 출력을 올바르게 해석한다면, 문제는 RenameEnglishLocale 마이그레이션의 execute("UPDATE users SET locale = 'en' WHERE locale = 'en_US'") 명령에서 발생했습니다.

이전에도 이 오류를 본 적이 있습니다. users 테이블에 내부 손상(internal corruption)이 있을 때 발생하는 문제입니다.

어떤 방식으로든 테이블에 중복된 “user” 레코드가 존재합니다. 이전 버전에서, 업그레이드 과정에서, 또는 갑작스러운 종료(rude shutdown) 시점에 들어온 것으로 보입니다. 정확히 왜 발생하는지는 아직 알지 못하지만, 실제로 발생한 것을 여러 번 확인했습니다.

두 가지 대안이 있습니다:

  1. 운이 좋다면 ./launcher start app을 실행한 후 rails c를 실행하고, DB.query('select * from users where username='Martina_S')를 실행한 뒤 마지막 Martina_S를 Martina_S1과 같은 이름으로 변경할 수 있습니다.

  2. 운이 나쁘면 앱을 시작할 수 없을 것입니다. 이 경우 데이터 컨테이너를 부팅하여 psql에서 위의 작업을 실행해야 합니다.

빠른 답변 감사합니다! 데이터 컨테이너를 어떻게 부팅하나요? ./launcher start app을 실행한 뒤 rails c를 입력해 보았지만, 데이터베이스가 실행되지 않아 Rails가 시작되지 않습니다. /etc/init.d/postgresql restart를 시도해 보았지만, 첫 번째 게시글에서 확인하신 오류가 발생했습니다. PostgreSQL 버전이 호환되지 않는다는 내용이었죠 (Debian LTS는 12.x만 지원하는데, 최근 Discourse 업그레이드가 데이터를 13.0으로 마이그레이션한 것 같습니다??). 저는 Rails 개발자이므로 SQL로 이 문제를 해결하는 데는 문제가 없습니다. 하지만 리눅스 명령줄에서 PostgreSQL 업데이트 실패로 보이는 문제를 어떻게 수정해야 할지 전혀 감이 잡히지 않습니다.

예제 데이터 컨테이너는 sample 디렉터리에서 확인할 수 있습니다.

올바른 위치를 지정하기만 하면, 컨테이너에 진입하여 psql를 실행할 수 있습니다.

네, 이미 13으로 업그레이드되었습니다.

@pfaffman 님이 수정해 주셨어요. 이 분 추천합니다 :slight_smile: