Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apps should not require SIDEKIQ_PRELOAD= with sidekiqswarm #4766

Open
mperham opened this issue Dec 18, 2020 · 25 comments
Open

Apps should not require SIDEKIQ_PRELOAD= with sidekiqswarm #4766

mperham opened this issue Dec 18, 2020 · 25 comments

Comments

@mperham
Copy link
Collaborator

mperham commented Dec 18, 2020

I've had two different Sidekiq Enterprise customers today who had to disable Bundler preload because their app would not boot successfully with sidekiqswarm. I'd like to investigate why so I can determine if there's a few widespread reasons that can be fixed or if this is something really app-specific.

Disabling Bundler preload causes your app to use more memory.

If any Enterprise customers have an app that does boot with SIDEKIQ_PRELOAD= bundle exec sidekiqswarm but does not boot successfully with bundle exec sidekiqswarm, please explain below if you know why. If you don't know why, put any error message and backtrace below. I would be interested in consulting with you to determine the reason and possibly fix it.

https://github.com/mperham/sidekiq/wiki/Ent-Multi-Process#bundler-preload

@nixme
Copy link

nixme commented Dec 19, 2020

Yes, we have to use SIDEKIQ_PRELOAD= as well or it won't boot. SIDEKIQ_PRELOAD= SIDEKIQ_PRELOAD_APP=1 works fine. We're on rails 5.2.4.4.

So I did some digging. It comes down to some gems need Rails fully-loaded before they can be required. So far I've found active_record_upsert and react-rails both cause issues.

If I mimic what Rails generates for config/application.rb in bin/sidekiqswarm, it works:

if groups.size > 0
  puts "[swarm] Preloading Bundler groups #{groups.inspect}"
  require 'rails/all'   # <--- this is the necessary part
  Bundler.require(*groups)
end

I figure you can't actually change sidekiq-ent to have a rails dependency like that. So I made the switch to gem 'rails', '5.2.4.4', require: 'rails/all' in the Gemfile, and it boots fine as well.

However, I'm unsure if there's downsides to that.

@mperham
Copy link
Collaborator Author

mperham commented Dec 19, 2020

That’s exactly the symptom I saw this morning, a gem failed to load because it was looking for Rails::VERSION.

@mperham
Copy link
Collaborator Author

mperham commented Dec 21, 2020

The only issue with requiring rails/all would be if you don't want to load certain subsystems within Rails. People often customize the require within config/application.rb, e.g.:

require 'rails'
%w(
  active_record/railtie
  action_controller/railtie
  action_view/railtie
  action_mailer/railtie
  active_job/railtie
  sprockets/railtie
).each do |railtie|
  begin
    require railtie
  rescue LoadError
  end
end

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

This example leaves out ActionText, ActionCable, etc. I think Rails is really missing a more explicit API for disabling subsystems.

@mperham
Copy link
Collaborator Author

mperham commented Dec 21, 2020

For the record:

  • active_record_upsert isn't using a Railtie at all to integrate with Rails. This is broken.
  • react-rails does have a Railtie but it looks like it has some class-level code which executes during the require that still depends on Rails APIs. Perhaps this line?

@mperham
Copy link
Collaborator Author

mperham commented Jan 21, 2021

Please add a comment if you find any other gems (and links to gem issues you open!) which break preload.

@pcreux
Copy link

pcreux commented Mar 9, 2021

I ran into a similar issue with scenic: scenic-views/scenic#313

@dhnaranjo
Copy link

I'm running into this with react-rails. Wondering if you can recommend any fix, dumb hacks ok, @mperham.

@justin808
Copy link

justin808 commented Sep 30, 2021

Hi @mperham! I've experienced the same as #4766 (comment).

SIDEKIQ_PRELOAD_APP=1 SIDEKIQ_PRELOAD= SIDEKIQ_MAXMEM_MB=1700 bundle exec sidekiqswarm works

How worthwhile is it to do more than the workaround?

At the very least, this should go into the Wiki for troubleshooting as I lost some hours before I found this issue.

CACHE_WARMER=true READ_ONLY_MAINTENANCE_MODE=true SIDEKIQ_MAXMEM_MB=1700 bundle exec sidekiqswarm  bundle exec sidekiqswarm -e $RACK_ENV -C config/sidekiq_cache_warmer.yml
[swarm] Preloading Bundler groups ["default"]
bundler: failed to load command: sidekiqswarm (/app/vendor/bundle/ruby/2.7.0/bin/sidekiqswarm)
Traceback (most recent call last):
	24: from /app/bin/bundle:3:in `<main>'
	23: from /app/bin/bundle:3:in `load'
	22: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/exe/bundle:37:in `<top (required)>'
	21: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	20: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/exe/bundle:49:in `block in <top (required)>'
	19: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:24:in `start'
	18: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	17: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:30:in `dispatch'
	16: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	15: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	14: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	13: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:474:in `exec'
	12: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:28:in `run'
	11: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:63:in `kernel_load'
	10: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:63:in `load'
	 9: from /app/vendor/bundle/ruby/2.7.0/bin/sidekiqswarm:23:in `<top (required)>'
	 8: from /app/vendor/bundle/ruby/2.7.0/bin/sidekiqswarm:23:in `load'
	 7: from /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-ent-2.2.3/bin/sidekiqswarm:40:in `<top (required)>'
	 6: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler.rb:174:in `require'
	 5: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:50:in `require'
	 4: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:50:in `each'
	 3: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:61:in `block in require'
	 2: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:61:in `each'
	 1: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
/app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:66:in `require': cannot load such file -- cloudflare-rails (LoadError)
	28: from /app/bin/bundle:3:in `<main>'
	27: from /app/bin/bundle:3:in `load'
	26: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/exe/bundle:37:in `<top (required)>'
	25: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	24: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/exe/bundle:49:in `block in <top (required)>'
	23: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:24:in `start'
	22: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	21: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:30:in `dispatch'
	20: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	19: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	18: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	17: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli.rb:474:in `exec'
	16: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:28:in `run'
	15: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:63:in `kernel_load'
	14: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/cli/exec.rb:63:in `load'
	13: from /app/vendor/bundle/ruby/2.7.0/bin/sidekiqswarm:23:in `<top (required)>'
	12: from /app/vendor/bundle/ruby/2.7.0/bin/sidekiqswarm:23:in `load'
	11: from /app/vendor/bundle/ruby/2.7.0/gems/sidekiq-ent-2.2.3/bin/sidekiqswarm:40:in `<top (required)>'
	10: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler.rb:174:in `require'
	 9: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:50:in `require'
	 8: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:50:in `each'
	 7: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:57:in `block in require'
	 6: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:79:in `rescue in block in require'
	 5: from /app/vendor/bundle/ruby/2.7.0/gems/bundler-2.2.21/lib/bundler/runtime.rb:79:in `require'
	 4: from /app/vendor/bundle/ruby/2.7.0/gems/cloudflare-rails-2.2.0/lib/cloudflare/rails.rb:10:in `<top (required)>'
	 3: from /app/vendor/bundle/ruby/2.7.0/gems/cloudflare-rails-2.2.0/lib/cloudflare/rails.rb:10:in `require'
	 2: from /app/vendor/bundle/ruby/2.7.0/gems/cloudflare-rails-2.2.0/lib/cloudflare/rails/railtie.rb:3:in `<top (required)>'
	 1: from /app/vendor/bundle/ruby/2.7.0/gems/cloudflare-rails-2.2.0/lib/cloudflare/rails/railtie.rb:4:in `<module:Cloudflare>'
/app/vendor/bundle/ruby/2.7.0/gems/cloudflare-rails-2.2.0/lib/cloudflare/rails/railtie.rb:5:in `<module:Rails>': uninitialized constant Rails (NameError)

@mperham
Copy link
Collaborator Author

mperham commented Sep 30, 2021

The wiki is publicly editable.

That looks like an issue in cloudflare-rails. They don’t actually require “rails” so they are assuming that Rails is loaded first.

https://github.com/modosc/cloudflare-rails/blob/main/lib/cloudflare/rails/railtie.rb

@justin808
Copy link

By moving Rails earlier in the Gemfile, the problem went to another gem.

The suggestion to add: gem "rails", require: "rails/all" fixed the issue.

@patbenatar
Copy link

Looks like shoryuken can be added to the list of gems that break preload:

worker_1       | bundler: failed to load command: sidekiqswarm (/usr/local/bundle/bin/sidekiqswarm)
worker_1       | NameError: uninitialized constant ActiveJob::Base
worker_1       | Did you mean?  Base64
worker_1       |   /usr/local/bundle/gems/shoryuken-5.2.3/lib/shoryuken/extensions/active_job_extensions.rb:37:in `<top (required)>'
worker_1       |   /usr/local/bundle/gems/shoryuken-5.2.3/lib/shoryuken.rb:92:in `<top (required)>'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
worker_1       |   /usr/local/lib/ruby/2.7.0/bundler.rb:174:in `require'
worker_1       |   /usr/local/bundle/gems/sidekiq-ent-2.2.3/bin/sidekiqswarm:40:in `<top (required)>'
worker_1       |   /usr/local/bundle/bin/sidekiqswarm:23:in `load'
worker_1       |   /usr/local/bundle/bin/sidekiqswarm:23:in `<top (required)>'

As said above, setting both SIDEKIQ_PRELOAD_APP=1 SIDEKIQ_PRELOAD= fixes the problem. Adding require: "rails/all" also fixes the problem but we prefer to not require all and list the frameworks we want in application.rb

@mperham
Copy link
Collaborator Author

mperham commented Dec 10, 2021

Yeah, they are trying to extend Rails functionality at require time rather than in a Railtie initializer. Bad idea.

@patbenatar
Copy link

I suppose rather than require: "rails/all" you can just use Gemfile as your declaration of frameworks instead of application.rb, e.g:

gem "rails", "6.1.4.1", require: ["active_record/railtie", "action_controller/railtie", "action_mailer/railtie"]

@mperham
Copy link
Collaborator Author

mperham commented Dec 10, 2021 via email

@krschacht
Copy link

krschacht commented Jan 8, 2022

@mperham I just tried switching my worker from bundle exec sidekiq to bundle exec sidekiqswarm and I get the following issue on boot.

Note: I have SIDEKIQ_PRELOAD=default,staging

Any suggestions? Is this another example of what you're looking for?

2022-01-08T05:37:35.835999+00:00 heroku[sidekiq.1]: Starting process with command `bundle exec sidekiqswarm -C gems/background/config/sidekiq-base.yml`
2022-01-08T05:37:36.630458+00:00 heroku[sidekiq.1]: State changed from starting to up
2022-01-08T05:37:39.076943+00:00 app[sidekiq.1]: [swarm] Preloading Bundler groups ["default", "staging"]
2022-01-08T05:37:43.903562+00:00 app[sidekiq.1]: bundler: failed to load command: sidekiqswarm (/app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm)
2022-01-08T05:37:43.904033+00:00 app[sidekiq.1]: pid=4 tid=18o8 INFO: Booting Sidekiq 6.3.1 with redis options {}
2022-01-08T05:37:43.904270+00:00 app[sidekiq.1]: /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:30:in `<module:SchemaDumper>': uninitialized constant ActiveRecord::SchemaDumper (NameError)
2022-01-08T05:37:43.904292+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:5:in `<module:Scenic>'
2022-01-08T05:37:43.904307+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:3:in `<top (required)>'
2022-01-08T05:37:43.904319+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic.rb:6:in `<top (required)>'
2022-01-08T05:37:43.904329+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:4:in `block in <top (required)>'
2022-01-08T05:37:43.904340+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:3:in `each'
2022-01-08T05:37:43.904351+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:3:in `<top (required)>'
2022-01-08T05:37:43.904361+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:60:in `require'
2022-01-08T05:37:43.904387+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
2022-01-08T05:37:43.904398+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `each'
2022-01-08T05:37:43.904408+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `block in require'
2022-01-08T05:37:43.904418+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `each'
2022-01-08T05:37:43.904428+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `require'
2022-01-08T05:37:43.904438+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler.rb:175:in `require'
2022-01-08T05:37:43.904464+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-ent-2.3.0/bin/sidekiqswarm:40:in `<top (required)>'
2022-01-08T05:37:43.904474+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm:23:in `load'
2022-01-08T05:37:43.904485+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm:23:in `<top (required)>'
2022-01-08T05:37:43.904495+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
2022-01-08T05:37:43.904505+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
2022-01-08T05:37:43.904515+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
2022-01-08T05:37:43.904540+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
2022-01-08T05:37:43.904550+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
2022-01-08T05:37:43.904561+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
2022-01-08T05:37:43.904571+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
2022-01-08T05:37:43.904581+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
2022-01-08T05:37:43.904591+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
2022-01-08T05:37:43.904609+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
2022-01-08T05:37:43.904624+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
2022-01-08T05:37:43.904634+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
2022-01-08T05:37:43.904644+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/exe/bundle:37:in `<top (required)>'
2022-01-08T05:37:43.904655+00:00 app[sidekiq.1]: from /app/bin/bundle:113:in `load'
2022-01-08T05:37:43.904665+00:00 app[sidekiq.1]: from /app/bin/bundle:113:in `<main>'
2022-01-08T05:37:44.105583+00:00 heroku[sidekiq.1]: Process exited with status 1
2022-01-08T05:37:44.199170+00:00 heroku[sidekiq.1]: State changed from up to crashed
2022-01-08T05:37:44.207549+00:00 heroku[sidekiq.1]: State changed from crashed to starting
2022-01-08T05:37:53.002252+00:00 heroku[sidekiq.1]: Starting process with command `bundle exec sidekiqswarm -C gems/background/config/sidekiq-base.yml`
2022-01-08T05:37:53.596309+00:00 heroku[sidekiq.1]: State changed from starting to up
2022-01-08T05:37:54.964436+00:00 app[sidekiq.1]: [swarm] Preloading Bundler groups ["default", "staging"]
2022-01-08T05:37:58.617761+00:00 heroku[sidekiq.1]: Process exited with status 1
2022-01-08T05:37:58.761657+00:00 heroku[sidekiq.1]: State changed from up to crashed
2022-01-08T05:37:58.481829+00:00 app[sidekiq.1]: bundler: failed to load command: sidekiqswarm (/app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm)
2022-01-08T05:37:58.482131+00:00 app[sidekiq.1]: pid=4 tid=18o8 INFO: Booting Sidekiq 6.3.1 with redis options {}
2022-01-08T05:37:58.482305+00:00 app[sidekiq.1]: /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:30:in `<module:SchemaDumper>': uninitialized constant ActiveRecord::SchemaDumper (NameError)
2022-01-08T05:37:58.482314+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:5:in `<module:Scenic>'
2022-01-08T05:37:58.482316+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic/schema_dumper.rb:3:in `<top (required)>'
2022-01-08T05:37:58.482325+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/scenic-1.5.4/lib/scenic.rb:6:in `<top (required)>'
2022-01-08T05:37:58.482326+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:4:in `block in <top (required)>'
2022-01-08T05:37:58.482336+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:3:in `each'
2022-01-08T05:37:58.482337+00:00 app[sidekiq.1]: from /app/gems/vizz_account/lib/vizz_account.rb:3:in `<top (required)>'
2022-01-08T05:37:58.482346+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:60:in `require'
2022-01-08T05:37:58.482349+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
2022-01-08T05:37:58.482359+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `each'
2022-01-08T05:37:58.482361+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:55:in `block in require'
2022-01-08T05:37:58.482364+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `each'
2022-01-08T05:37:58.482373+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/runtime.rb:44:in `require'
2022-01-08T05:37:58.482374+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler.rb:175:in `require'
2022-01-08T05:37:58.482384+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/sidekiq-ent-2.3.0/bin/sidekiqswarm:40:in `<top (required)>'
2022-01-08T05:37:58.482392+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm:23:in `load'
2022-01-08T05:37:58.482400+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/bin/sidekiqswarm:23:in `<top (required)>'
2022-01-08T05:37:58.482408+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
2022-01-08T05:37:58.482416+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
2022-01-08T05:37:58.482424+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
2022-01-08T05:37:58.482425+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
2022-01-08T05:37:58.482437+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
2022-01-08T05:37:58.482438+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
2022-01-08T05:37:58.482447+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
2022-01-08T05:37:58.482455+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
2022-01-08T05:37:58.482462+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
2022-01-08T05:37:58.482470+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
2022-01-08T05:37:58.482478+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
2022-01-08T05:37:58.482486+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
2022-01-08T05:37:58.482494+00:00 app[sidekiq.1]: from /app/vendor/bundle/ruby/3.0.0/gems/bundler-2.2.33/exe/bundle:37:in `<top (required)>'
2022-01-08T05:37:58.482502+00:00 app[sidekiq.1]: from /app/bin/bundle:113:in `load'
2022-01-08T05:37:58.482504+00:00 app[sidekiq.1]: from /app/bin/bundle:113:in `<main>'

@mperham
Copy link
Collaborator Author

mperham commented Jan 9, 2022

If you look at the top of the backtrace, the error starts in the scenic gem; the issue is almost always that they are integrating with Rails incorrectly. Update that gem and if the problem doesn't go away, open an issue with them.

@pcreux
Copy link

pcreux commented Jan 9, 2022

@krschacht

I ran into a similar issue with scenic: scenic-views/scenic#313

@krschacht
Copy link

krschacht commented Jan 14, 2022

@mperham While I'm working to resolve the issues with the scenic gem, is there any way to change the way to fully load rails and then launch sidekiqswarm afterwards?

This question probably doesn't make a lot of sense. To restate it: rails is loading fine. I get that I have a gem which is breaking the rails loading process and somehow the way sidekiqswarm initializes, it's hitting this issue. Can I cause sidekiqwarm to initialize in a way that more closely mirrors how rails itself loads so that I can sidestep this issue, for now?

@mperham
Copy link
Collaborator Author

mperham commented Jan 14, 2022

@krschacht Because scenic is broken, you need to preload Rails before any other gems. It's been mentioned above:

gem "rails", require: "rails/all"

@maxwell
Copy link

maxwell commented Jan 26, 2022

running into this issue with latest version of Rails 7 support with the paper_trail gem https://github.com/paper-trail-gem/paper_trail

@mperham
Copy link
Collaborator Author

mperham commented Jan 26, 2022 via email

@maxwell
Copy link

maxwell commented Jan 26, 2022

is there a way to give the maintainer a repo that includes sidekiq-ent so I can make a repo that reproduces the issue for them?

Did you open an issue with them?

On Tue, Jan 25, 2022 at 21:03 Maxwell Salzberg @.> wrote: running into this issue with latest version of Rails 7 support with the paper_trail gem https://github.com/paper-trail-gem/paper_trail — Reply to this email directly, view it on GitHub <#4766 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAWX7ACOPQLVJ4ULA3UKDUX56A5ANCNFSM4VBVR6YQ . You are receiving this because you were mentioned.Message ID: @.>

@mperham
Copy link
Collaborator Author

mperham commented Jan 26, 2022 via email

@technicalpickles
Copy link

technicalpickles commented Jul 27, 2023

I ran into this when trying to use active_storage_validations. It was another case of the gem having dependencies on rails components, but not requiring them, so I filed an issue: igorkasyanchuk/active_storage_validations#197

I confirmed SIDEKIQ_PRELOAD= bin/sidekiqswarm does work.

require: "rails/all" does not work though. The stack traces are too long and have application specific code, but it involves failing to find constants from the app itself.

@technicalpickles
Copy link

I found a workaround in case it's useful for others. I updated our Gemfile to add a require to the offending gem, ie:

gem 'active_storage_validations', require: ['active_model', 'active_storage_validations']

It still should be fixed upstream, but at least this helps unblock without having to wait for / make for a fix, and have it released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants