求助!升级导致彻底失败

您好,

在执行最近的升级(从某个 6 版本到 7 版本)时,rake db:migrate 因疑似重复用户名而失败。由于我不太熟悉 Linux 命令行,我尝试进入 Rails 控制台进行修复,但控制台无法加载,因为它无法连接到数据库。随后我搜索并尝试执行 /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 个赞

中间某个环节出现了一个漏洞,导致用户名可以包含不同的大小写。随后该问题已被修复,不再允许这种情况。

你可能可以重新启动旧的容器,并通过用户界面进行修复。

但如果你已经有一段时间没有通过命令行进行升级,那么还会涉及数据库升级,这会让情况变得更加复杂。

如果问题并不比这更严重,我将在明天上午(太平洋时间)修复它: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 个赞

我之前遇到过这个错误,它通常发生在用户表出现内部损坏时。

不知何故,表中存在重复的"user"记录,这可能是早期版本、升级过程或异常关闭时悄然引入的。我尚不清楚具体原因,但确实见过这种情况。

你有两种选择:

  1. 如果运气好,可以依次执行 ./launcher start apprails 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 个赞

请在 sample 目录中查看示例数据容器。

你只需将其指向正确的位置,然后就能进入容器并运行 psql。

是的,你已经升级到 13 版本了。

1 个赞

@pfaffman 已经修复了。我推荐这个人 :slight_smile:

9 个赞

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