简体   繁体   English

无法修改冻结的 Hash - rails 6 heroku

[英]can't modify frozen Hash - rails 6 heroku

After updating to Rails 6 and pushing to Heroku, I'm getting this error.更新到 Rails 6 并推送到 Heroku 后,我收到此错误。 I can't find any similar issues, and don't understand what the error is trying to say.我找不到任何类似的问题,也不明白错误想说什么。

I've confirmed that the database, username, password, and host location are all accurate.我已经确认数据库、用户名、密码和主机位置都是准确的。

2021-05-04T15:01:04.536128+00:00 heroku[worker.1]: State changed from crashed to starting
2021-05-04T15:01:24.086595+00:00 heroku[worker.1]: Starting process with command `bundle exec sidekiq -e production -C config/sidekiq.yml`
2021-05-04T15:01:24.897839+00:00 heroku[worker.1]: State changed from starting to up
2021-05-04T03:11:56.114768+00:00 app[worker.2]: I, [2021-05-04T03:11:56.114626 #4]  INFO -- sentry: ** [Raven] Raven 3.1.2 ready to catch errors
    2021-05-04T03:11:56.708882+00:00 app[worker.2]: can't modify frozen Hash: {:adapter=>"postgresql", :pool=>5, :timeout=>10000, :database=>"real_db", :username=>"real_username", :password=>"real_password", :host=>"real_location.compute-1.amazonaws.com", :port=>5432}
    2021-05-04T03:11:56.708922+00:00 app[worker.2]: /app/config/initializers/sidekiq.rb:6:in `block in <top (required)>'
    2021-05-04T03:11:56.708923+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-5.2.9/lib/sidekiq.rb:75:in `configure_server'
    2021-05-04T03:11:56.708924+00:00 app[worker.2]: /app/config/initializers/sidekiq.rb:5:in `<top (required)>'
    2021-05-04T03:11:56.708925+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:326:in `load'
    2021-05-04T03:11:56.708926+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:326:in `block in load'
    2021-05-04T03:11:56.708926+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'
    2021-05-04T03:11:56.708927+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:326:in `load'
    2021-05-04T03:11:56.708927+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:681:in `block in load_config_initializer'
    2021-05-04T03:11:56.708927+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/notifications.rb:205:in `instrument'
    2021-05-04T03:11:56.708928+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:680:in `load_config_initializer'
    2021-05-04T03:11:56.708928+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
    2021-05-04T03:11:56.708929+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:633:in `each'
    2021-05-04T03:11:56.708929+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:633:in `block in <class:Engine>'
    2021-05-04T03:11:56.708929+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:32:in `instance_exec'
    2021-05-04T03:11:56.708930+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:32:in `run'
    2021-05-04T03:11:56.708930+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:61:in `block in run_initializers'
    2021-05-04T03:11:56.708930+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
    2021-05-04T03:11:56.708931+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    2021-05-04T03:11:56.708931+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    2021-05-04T03:11:56.708931+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
    2021-05-04T03:11:56.708932+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    2021-05-04T03:11:56.708932+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:50:in `each'
    2021-05-04T03:11:56.708932+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:50:in `tsort_each_child'
    2021-05-04T03:11:56.708933+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:415:in `call'
    2021-05-04T03:11:56.708933+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:415:in `each_strongly_connected_component_from'
    2021-05-04T03:11:56.708933+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
    2021-05-04T03:11:56.708934+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:347:in `each'
    2021-05-04T03:11:56.708934+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:347:in `call'
    2021-05-04T03:11:56.708934+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
    2021-05-04T03:11:56.708935+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
    2021-05-04T03:11:56.708935+00:00 app[worker.2]: /app/vendor/ruby-3.0.1/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
    2021-05-04T03:11:56.708935+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:60:in `run_initializers'
    2021-05-04T03:11:56.708935+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.3.1/lib/rails/application.rb:384:in `initialize!'
    2021-05-04T03:11:56.708936+00:00 app[worker.2]: /app/config/environment.rb:5:in `<top (required)>'
    2021-05-04T03:11:56.708936+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'
    2021-05-04T03:11:56.708936+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require'
    2021-05-04T03:11:56.708937+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'
    2021-05-04T03:11:56.708937+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'
    2021-05-04T03:11:56.708937+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:288:in `boot_system'
    2021-05-04T03:11:56.708938+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-5.2.9/lib/sidekiq/cli.rb:46:in `run'
    2021-05-04T03:11:56.708938+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-5.2.9/bin/sidekiq:12:in `<top (required)>'
    2021-05-04T03:11:56.708938+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/bin/sidekiq:23:in `load'
    2021-05-04T03:11:56.708939+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/bin/sidekiq:23:in `<top (required)>'
    2021-05-04T03:11:56.708939+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli/exec.rb:63:in `load'
    2021-05-04T03:11:56.708945+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli/exec.rb:63:in `kernel_load'
    2021-05-04T03:11:56.708945+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli/exec.rb:28:in `run'
    2021-05-04T03:11:56.708945+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli.rb:494:in `exec'
    2021-05-04T03:11:56.708946+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    2021-05-04T03:11:56.708946+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    2021-05-04T03:11:56.708946+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    2021-05-04T03:11:56.708947+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli.rb:30:in `dispatch'
    2021-05-04T03:11:56.708947+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    2021-05-04T03:11:56.708947+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/cli.rb:24:in `start'
    2021-05-04T03:11:56.708948+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/exe/bundle:49:in `block in <top (required)>'
    2021-05-04T03:11:56.708948+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
    2021-05-04T03:11:56.708948+00:00 app[worker.2]: /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.16/exe/bundle:37:in `<top (required)>'
    2021-05-04T03:11:56.708964+00:00 app[worker.2]: /app/bin/bundle:3:in `load'
    2021-05-04T03:11:56.708965+00:00 app[worker.2]: /app/bin/bundle:3:in `<main>'
    2021-05-04T03:11:56.773370+00:00 heroku[worker.2]: Process exited with status 1
    2021-05-04T03:11:57.188558+00:00 heroku[worker.2]: State changed from up to crashed

Seems to be referencing line 6 of the sidekiq initializer, but I see nothing suspect about it.似乎是在引用 sidekiq 初始化程序的第 6 行,但我看不出有什么可疑之处。 In fact, it really hasn;t been changed since setting it up a couple years ago:事实上,自从几年前设置它以来,它真的没有改变过:

if Rails.env.production?

require 'sidekiq/web'

  Sidekiq.configure_server do |config|
    ActiveRecord::Base.configurations[Rails.env.to_s]['pool'] = 30
  end
end

sidekiq.yml: sidekiq.yml:

development:
  :concurrency: 5
production:
  :concurrency: 20
:queues:
  - default
  - mailers

Procfile档案

web: bundle exec puma -p $PORT  ./config.ru
web: bundle exec puma -C config/puma.rb
redis: redis-server
worker: bundle exec sidekiq -e production -C config/sidekiq.yml

Looks like that configuration hash has been frozen since this commit: https://github.com/rails/rails/commit/2291d4a94fd3aff61c77d1a2ad1e6186ed4c80a2 .看起来该配置 hash 自此提交以来已被冻结: https://github.com/rails/rails/commit/2291d4a94fd3aff61c77d1a2ad1e6186ed4c80a2 ActiveRecord::Base.configurations[Rails.env.to_s]['pool'] = 30 in your Sidekiq initializer is attempting to mutate the frozen hash.您的 Sidekiq 初始化程序中的ActiveRecord::Base.configurations[Rails.env.to_s]['pool'] = 30正试图改变冻结的 hash。

If you're configuring your database in a config.database.yml file, you can add or update the size of the production pool there, and remove the whole Sidekiq.configure_server block:如果您在config.database.yml文件中配置数据库,您可以在那里添加或更新生产池的大小,并删除整个Sidekiq.configure_server块:

production:
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>
  pool: 30

If you're configuring your database entirely via DATABASE_URL environment variable, you would just need to ensure the pool size is specified at the end of the URL:如果您完全通过DATABASE_URL环境变量配置数据库,则只需确保在 URL 的末尾指定池大小:

postgresql://username:password@host:5432/database-name?pool=30

More info here: https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database更多信息: https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database

Sidekiq initializer: Sidekiq 初始化器:

require 'sidekiq/web' if Rails.env.production?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM