ヘルプ!アップグレードが完全な失敗につながる

こんにちは、

最新のアップグレード(バージョン 6 から 7 へ)を実行した際、重複したユーザー名が原因で rake db:migrate が失敗しました。Linux コマンドラインにはあまり慣れていないため、これを修正するために Rails コンソールに入ろうとしましたが、データベースに接続できないためコンソールが起動しませんでした。その後、Google で検索し /etc/init.d/postgresql restart を試みましたが、以下のエラーが発生しました:

[....] PostgreSQL 12 データベースサーバーを再起動中: main[....] 
エラー: /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" がステータス 1 で終了しました: 2021-03-08 20:19:10.354 UTC [763] 
FATAL: データベースファイルがサーバーと互換性がありません 2021-03-08 20:19:10.354 UTC [763] 
DETAIL: データディレクトリは PostgreSQL バージョン 13 で初期化されましたが、これはこのバージョン 12.3 (Debian 12.3-1.pgdg100+1) と互換性がありません。p[FAIL: サーバーを起動できませんでした。ログ出力を確認してください。... 失敗しました!
 失敗しました!

その後、/etc/init.d/postgresql restart version 12.3 を試みましたが、エラーは表示されなかったものの、他のメッセージも出ませんでした。それでも、psql にログインすることができません(少なくともこのフォーラムで見つけた sudo -u postgres psql discourse は使えません)。

サーバーを復元する方法をご教示いただけますでしょうか?また、なぜ最新のアップグレードでこれほど大きなエラーが発生したのでしょうか?私は 30 分インストールを使用しており、すべてが可能な限り標準的な設定になっています。また、修正を依頼するために報酬を支払うことも可能です。

「いいね!」 3

@pfaffman はこの種のサポートを専門としていますので、彼に連絡してみてください。

正確なエラーメッセージはありますか?少しスクロールが必要かもしれませんが、以下の点について知りたいです。

  1. 失敗したマイグレーションの名前
  2. 失敗の原因となったステートメント
「いいね!」 3

途中、大文字小文字が異なるユーザー名を許容するバグが存在しましたが、その後修正され、そのようなことが起きないようになりました。

古いコンテナを起動して UX を通じて修正できるかもしれません。

しかし、しばらくコマンドラインでのアップグレードを行っていない場合は、さらに複雑になるデータベースのアップグレードも必要となります。

問題がそれ以上深刻でなければ、明日の午前(太平洋時間)に修正いたします:Redirecting…

もし今夜中に完了させるために追加料金を支払いたい場合は、すぐに Jay@literatecomputing.com までメールしてください。少なくともサービスを復旧させることができるかもしれません。

「いいね!」 2

This is the output from the web interface:

*** Please be patient, next steps might take a while ***
********************************************************
Cycling Unicorn, to free up memory
Restarting unicorn pid: 46
Waiting for Unicorn to reload.
Waiting for Unicorn to reload..
Waiting for Unicorn to reload...
Waiting for Unicorn to reload....
Waiting for Unicorn to reload.....
Waiting for Unicorn to reload......
Waiting for Unicorn to reload.......
Waiting for Unicorn to reload........
Waiting for Unicorn to reload.........
Waiting for Unicorn to reload..........
Waiting for Unicorn to reload...........
Waiting for Unicorn to reload............
Stopping 3 Unicorn worker(s), to free up memory
Stopping job queue to reclaim memory, master pid is 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] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set without 'test development'`, and stop using this flag
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.7). We suggest you to upgrade to the version that created the lockfile by running `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

I then ran the update via SSH, hoping that that would be more robust (in 2020 there were a few months when the web interface refused to update anything and I always had to go via SSH). When I typed the update command on the commandline, it downloaded a bunch of stuff and eventually told me to run the rebuild app command. When I did that, the same error occurred. I cannot attest whether the surrounding lines were the same and I didn’t copy them, but it definitely had this index_username_on_users issue in the middle of the database migrations.

TL;DR: If I interpret the output correctly, the problem occurred in the RenameEnglishLocale migration on the execute("UPDATE users SET locale = 'en' WHERE locale = 'en_US'") command.

「いいね!」 1

このエラーは以前にも見たことがあります。users テーブルに内部破損が発生した場合に起こります。

何らかの理由で、テーブル内に重複する「user」レコードが存在してしまいます。これは以前のバージョン、アップグレード中、あるいは不意のシャットダウン時に混入してしまった可能性があります。なぜこのようなことが起こるのかは現在も正確にはわかりませんが、実際に発生したことはあります。

対処法は以下の 2 つがあります。

  1. 運が良ければ、./launcher start appを実行し、次に rails c を実行して、DB.query('select * from users where username='Martina_S') でクエリを実行し、最後の Martina_S というレコードを Martina_S1 のような名前に変更します。

  2. 運が悪ければアプリを起動できなくなります。その場合はデータコンテナを起動し、psql から上記の手順を実行する必要があります。

「いいね!」 1

迅速なご返信ありがとうございます!データコンテナを起動するにはどうすればよいでしょうか? ./launcher start app を実行し、続けて rails c と入力しましたが、データベースが起動していないため Rails が開始されません。/etc/init.d/postgresql restart を試しましたが、最初の投稿でお見せしたエラーが発生しました。PostgreSQL のバージョンが互換性がないという内容のようです(Debian LTS は 12.x のみサポートしており、最新の Discourse アップグレードにより、データが 13.0 に移行されたようですが??)。SQL で修正しても構いません。私は Rails 開発者ですから。しかし、Linux コマンドライン上で PostgreSQL の更新が失敗したように見える問題をどのように修正すればよいのか、見当もつきません。

「いいね!」 1

サンプルディレクトリにあるデータコンテナの例を確認してください。

正しい場所を指し示すだけで、コンテナに入り、psql を実行できるようになります。

はい、すでにバージョン 13 にアップグレード済みです。

「いいね!」 1

@pfaffman さんが修正しました。この方をぜひおすすめします :slight_smile:

「いいね!」 9

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.