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

Specifying queues for active_storage breaks Sidekiq #40730

Closed
mperham opened this issue Dec 2, 2020 · 11 comments
Closed

Specifying queues for active_storage breaks Sidekiq #40730

mperham opened this issue Dec 2, 2020 · 11 comments

Comments

@mperham
Copy link
Contributor

mperham commented Dec 2, 2020

The code here specifies two new queues for active_storage jobs.

active_storage.queues.analysis = :active_storage_analysis
active_storage.queues.purge = :active_storage_purge

The issue is that each user must configure Sidekiq to listen to any new queues, meaning that every Sidekiq user who upgrades to Rails 6.1 will need to manually add these queues to their config. This is a major footgun.

https://twitter.com/stevepolitodsgn/status/1333976003505434626

My suggestion is to not specify queues but let the jobs use the system's default queue:

  active_storage.queues.analysis = nil
  active_storage.queues.purge    = nil

And allow users to override that config if they want these job types to go into other, custom queues.

@georgeclaghorn
Copy link
Contributor

Other framework components have default queues, too. Action Mailer’s deliver_later feature has defaulted to the :mailers queue since 2014. Would you recommend changing all of them?

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

ActionMailer was updated to default to "default" for its queue, because it was breaking for so many Sidekiq users. I don't believe mailers is used by new Rails apps but obviously the option remains for people who want to configure it so.

https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_name.rb#L9

I'm suggesting you not explicitly configure a queue for each job type, let them use the default and everything should work. If the user wants to reroute them to a custom queue, that's their decision. For example some people use queue naming to encode priority: low, default, high, critical and they would want to select a priority queue for each feature:

config.active_storage.queues.purge    = :low

@georgeclaghorn
Copy link
Contributor

georgeclaghorn commented Dec 2, 2020

ActionMailer was updated to default to "default" for its queue, because it was breaking for so many Sidekiq users. I don't believe mailers is used by new Rails apps but obviously the option remains for people who want to configure it so.

Could you point to where that happened? As far as I can tell, the default for Action Mailer is still :mailers:

cattr_accessor :deliver_later_queue_name, default: :mailers

queue_as { ActionMailer::Base.deliver_later_queue_name }

This is where the default would’ve been changed and I’m not seeing anything there.

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

Good to know, I guess I'm mistaken.

The bigger picture still remains: will Rails continue to add new queue names for each release, requiring users to configure Rails or Sidekiq manually so they work together? I want to get to a place where new Rails features work by default on Sidekiq.

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

I wrote this to document the current state. Let me know if there's any Rails internal queues I missed or if it is missing detail. Does Basecamp run Resque using QUEUE=* so no one has to manually enable queue processing for new queues?

@rafaelfranca
Copy link
Member

I personally think we should use the default queue by default, but another way forward is to use the Sidekiq::Engine to set the default queue of those components to the default queue on sidekiq if users didn't override it.

@georgeclaghorn
Copy link
Contributor

👍 for switching to :default everywhere.

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

That's certainly possible. I'm reluctant to add additional "magic" to override Rails defaults. Each version of Rails has different queues to configure and future versions would require future overrides due to new queues.

We're adding more config to overrule more config, Rails -> Sidekiq::Engine -> User config, that mountain of config leads to madness. Just remove all of it (within reason, I get that backwards compatibility is a thing) and let the job runner's defaults work.

@rafaelfranca
Copy link
Member

If @georgeclaghorn is ok with changing the queue everywhere, I think we can just change the defaults. The problem is that I don't feel comfortable of doing this change in the rc cycle given people may already changed their sidekiq config to use the new queues.

@mperham do you think we do embrace this change right now or wait for 6.2?

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

Yeah, I know it's really late in the release cycle. I wish I had known about this earlier.

Per the tweet linked above, I'm worried about the many Rails/Sidekiq users who will upgrade to 6.1, use these features and have it silently break. If we assume that everyone will be processing the default queue, I don't think it will break anyone to switch the default now. If you want to leave mailers as is for legacy reasons but switch active_storage, that's still an improvement.

@mperham
Copy link
Contributor Author

mperham commented Dec 2, 2020

And don't be afraid to mention me if there are further queue things you want to discuss. It's literally my job to make Sidekiq work great with Rails.

rafaelfranca added a commit to rafaelfranca/omg-rails that referenced this issue Dec 8, 2020
…ter's default

`config.active_storage.queues.analysis`:
From `:active_storage_analysis` to `nil`.

`config.active_storage.queues.purge`:
From `:active_storage_purge` to `nil`.

`config.action_mailbox.queues.incineration`:
From `:action_mailbox_incineration` to `nil`.

`config.action_mailbox.queues.routing`:
From `:action_mailbox_routing` to `nil`.

`config.action_mailer.deliver_later_queue_name`:
From `:mailers` to `nil`.

Fixes rails#40730.
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

3 participants