Help! Upgrade led to complete fail

Hi,

When running most recent upgrade (something 6 to 7), rake db:migrate failed because of a supposed duplicate username. As I’m not really comfortable with the Linux commandline, I then tried to enter the rails console in order to fix this but the console won’t load because it couldn’t connect to the database. I then googled and tried /etc/init.d/postgresql restart but that failed with:

[....] 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!

I then tried /etc/init.d/postgresql restart version 12.3, that didn’t give an error but also no other message. And it’s still impossible to log into psql (at least using sudo -u postgres psql discourse which I found on this forum).

Can anyone advise how to restore the server? And why did the latest upgrade cause such a huge error anyway? I used the 30-minute installation, everything is as standard as can be. I’m also ready to pay someone to fix this.

3 Likes

@pfaffman specializes in this kind of support, perhaps contact him.

Do you have the exact failure? you may need a bit of scrolling, but I am curious about

  1. The name of the migration that failed
  2. The statement that caused it to fail
3 Likes

There was a bug somewhere along the way that allowed usernames with different capitalization. And then it got fixed so that it doesn’t.

You might be able to crank up the old container and fix it with the ux.

But if you haven’t done a command line upgrade for a while, then there’s also a database upgrade,which further complicates things.

If it’s not much worse than that, I’ll fix it tomorrow morning pacific time Automatic Rebuilds when They Are Needed — Literate Computing, LLC

Is you want to pay more to get it done tonight, email Jay@literatecomputing.com soon and I might be able to at least get it back up.

2 Likes

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 Like

I have seen this error before, it happens when there is an internal corruption in the users table.

Somehow you have a duplicate “user” record in the table, it snuck in during an earlier version or during an upgrade or during a rude shutdown. I still do not know exactly why it happens, but I have seen it happen.

You have 2 alternatives:

  1. If you are lucky ./launcher start app then rails c then DB.query('select * from users where username='Martina_S') then rename the last Martina_S to something like Martina_S1

  2. If you are not lucky you will not be able to start the app, then you are going to need to boot a data container and run the above from psql

1 Like

Thank you for your quick replies! How do I boot a data container? I tried ./launcher start app and then rails c, but Rails won’t start because the database is not running. I tried /etc/init.d/postgresql restart but got the error you see in the initial post, something about the Postgresql version being incompatible (Debian LTS only supports 12.x, while the latest Discourse upgrade appears to have migrated my data to 13.0??). I’d be fine fixing this in SQL, I’m a Rails developer after all, but I have no idea how to fix what looks like a botched Postgresql update on a Linux commandline.

1 Like

Look in the sample dir for an example data container

You just need to point it at the right location, then you should be able to enter the container and run psql

Yeah you are already upgraded to 13

1 Like

@pfaffman fixed it. I recommend this guy :slight_smile:

8 Likes

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