引导 Pups 失败::ExecError 'bundle exec rake db:migrate' 失败,返回 exec 失败,参数为 2.9.0.beta4 到 2.9.0.beta5

我两个月前将 Discourse 升级到了 2.9.0.beta4 34fba417f1。不幸的是,我忘记了在升级页面重新检查 ./launcher rebuild app。当我两天前尝试重建时,磁盘空间不足。我的备份是 130 MB。

所以,我升级了我的 droplet 并将其大小从 25 GB 调整为 50 GB。

当我尝试重建应用程序时,出现了这个错误。

102:M 11 Jun 2022 13:40:32.373 * DB 已保存到磁盘

102:M 11 Jun 2022 13:40:32.374 # Redis 已准备好退出,再见...

失败

--------------------

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1605 exit 1>

失败位置:/usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'

exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}

bootstrap failed with exit code 1

**引导失败** 请向上滚动查找更早的错误消息,可能不止一个。

./discourse-doctor 可能有助于诊断问题。

9a7eb814ecd8b017057c4f6b9c54fc1c65520c7b5e9427984ee6fc326246b170

我尝试过但都失败的事情:

  1. ./discourse-doctor:我仍然不知道接下来该做什么。
  2. 将我的实例迁移到新服务器并恢复备份。我认为它失败是因为我的 Discourse 不是最新版本。当前元数据版本是 20220526203356,我的版本是 20220407195246。我有错误日志。

我想要做的一些想法:

  1. 在新的 digitalocean 服务器上安装相同的 Discourse commit (34fba417f1) 并恢复我的备份。但是,我找不到如何安装相同版本的线索。我尝试了一些线索但失败了。例如 这个
  2. 使用相同的 Discourse 版本并恢复我的备份,但我不知道如何操作。

我的插件:

  1. discourse-canned-replies
  2. discourse-push-notifications

Ubuntu 版本 20.04.4 LTS。

谢谢

请提供日志文件中该代码片段之前的 60 行。

另外,请显示在命令行中键入 free 命令的输出。

3 个赞

Thank you for your kindness and response Mr Ed.

This error still occur when I try to upgrade from 2.9.0.beta4 to 2.9.0.beta5.

Here is 60 lines precede my snippet above to the end:

Caused by:
PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type integer: "[]"
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:765:in `block in log'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:756:in `log'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:932:in `block in method_missing'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:900:in `block in say_with_time'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:900:in `say_with_time'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:921:in `method_missing'
/var/www/discourse/db/migrate/20220330160747_copy_site_settings_uploads_to_upload_references.rb:5:in `up'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:873:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:873:in `exec_migration'
/var/www/discourse/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/var/www/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:853:in `block in migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:852:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1046:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/transactions.rb:209:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1411:in `ddl_transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1333:in `each'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1282:in `block in migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1282:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1117:in `up'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/migration.rb:1092:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/var/www/discourse/lib/tasks/db.rake:231:in `block (2 levels) in <main>'
/var/www/discourse/lib/distributed_mutex.rb:33:in `block in synchronize'
/var/www/discourse/lib/distributed_mutex.rb:29:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:29:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:14:in `synchronize'
/var/www/discourse/lib/tasks/db.rake:214:in `block in <main>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I, [2022-06-19T10:38:18.212808 #1]  INFO -- : == 20220330160747 CopySiteSettingsUploadsToUploadReferences: migrating ========
-- execute("WITH site_settings_uploads AS (\n  SELECT id, unnest(string_to_array(value, '|'))::integer upload_id\n  FROM site_settings\n  WHERE data_type = 17\n  UNION\n  SELECT id, value::integer\n  FROM site_settings\n  WHERE data_type = 18 AND value != ''\n)\nINSERT INTO upload_references(upload_id, target_type, target_id, created_at, updated_at)\nSELECT site_settings_uploads.upload_id, 'SiteSetting', site_settings_uploads.id, uploads.created_at, uploads.updated_at\nFROM site_settings_uploads\nJOIN uploads ON uploads.id = site_settings_uploads.upload_id\nON CONFLICT DO NOTHING\n")

I, [2022-06-19T10:38:18.213900 #1]  INFO -- : Terminating async processes
I, [2022-06-19T10:38:18.214413 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
I, [2022-06-19T10:38:18.214817 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 102
2022-06-19 10:38:18.215 UTC [41] LOG:  received fast shutdown request
102:signal-handler (1655635098) Received SIGTERM scheduling shutdown...
2022-06-19 10:38:18.225 UTC [41] LOG:  aborting any active transactions
2022-06-19 10:38:18.235 UTC [41] LOG:  background worker "logical replication launcher" (PID 50) exited with exit code 1
2022-06-19 10:38:18.236 UTC [45] LOG:  shutting down
102:M 19 Jun 2022 10:38:18.286 # User requested shutdown...
102:M 19 Jun 2022 10:38:18.286 * Saving the final RDB snapshot before exiting.
2022-06-19 10:38:18.301 UTC [41] LOG:  database system is shut down
102:M 19 Jun 2022 10:38:18.515 * DB saved on disk
102:M 19 Jun 2022 10:38:18.516 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1602 exit 1>
Location of failure: /usr/local/lib/ruby/gems/2.7.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
732ef5a2f11cd751fa276bc9936bfa82c95292dc11894b0dba69fac64d6b0848

I think, there are more than one error. I try to take the main error message before 60 lines above:

First

I, [2022-06-19T10:38:11.832691 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
2022-06-19 10:38:18.154 UTC [1616] discourse@discourse ERROR:  invalid input syntax for type integer: "[]"
2022-06-19 10:38:18.154 UTC [1616] discourse@discourse STATEMENT:  WITH site_settings_uploads AS (
          SELECT id, unnest(string_to_array(value, '|'))::integer upload_id
          FROM site_settings
          WHERE data_type = 17
          UNION
          SELECT id, value::integer
          FROM site_settings
          WHERE data_type = 18 AND value != ''
        )
        INSERT INTO upload_references(upload_id, target_type, target_id, created_at, updated_at)
        SELECT site_settings_uploads.upload_id, 'SiteSetting', site_settings_uploads.id, uploads.created_at, uploads.updated_at
        FROM site_settings_uploads
        JOIN uploads ON uploads.id = site_settings_uploads.upload_id
        ON CONFLICT DO NOTHING

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type integer: "[]"
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'

Second

Caused by:
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type integer: "[]"
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-7.0.3/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'

thank you

1 个赞

最近也有人遇到了类似的错误 - https://meta.discourse.org/t/unable-to-restore-update-discourse-pg-error-invalid-input-syntax-for-type-integer/229828,这是由于 selectable_avatar 站点设置字段中存在一些杂乱的数据阻止了其迁移。有一个使用 rails console 的手动解决方法,但是你需要熟悉使用 rails console。

如果 rails console 超出了你的舒适区,@david 提到如果还有更多报告,他会创建一个自动调整。:crossed_fingers:

5 个赞

供参考:这不应该是恢复失败的原因。如果你恢复到的实例比你的备份新,你应该没问题。

如果你在同一台主机上升级,也会发生这种情况。

2 个赞

我认为这会在合并后立即解决问题 :slightly_smiling_face: :+1:

6 个赞

谢天谢地,终于完成了。我的 Discourse 已经可以再次运行了。 :dancer:
我的 Discourse 现在每月 10 美元(50 GB)。 :sweat_smile:

我通过 Jammy 的提示解决了这个问题,方法是使用以下命令进入 rails 控制台:

cd /var/discourse
./launcher enter app
rails c
SiteSetting.selectable_avatars = ""

我使用了两次 exit 来退出 rails 控制台。

然后,像往常一样重建应用程序。

当我执行 ./launcher enter apprails c 时,我收到了相同的消息。我不记得是哪个命令了。
但至少,我的 Discourse 恢复了。 :partying_face:

感谢 Ed_s、Jammy 和 Richard 的善良、回应和分享。愿所有美好的事物永远伴随着你们。

另外,我也很感谢 VPS 的调整大小和快照功能,我会尽量记住在成功重建应用程序后始终打开升级页面。

谢谢……

5 个赞

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