Repository navigation
Deprecate setting config.active_job.enqueue_after_transaction_commit - #53375
Conversation
fe85eb7 to
caad5cd
Compare
Also change the configuration to be a boolean instead of a symbol. The value of this setting isn't delegated to the queue adapter anymore, since the behavior that this setting controls is too dangerous to leave this change of behavior as something that users don't control. Fixes #52675.
caad5cd to
582f91e
Compare
|
@rafaelfranca, just in case it was an oversight or unintended: it seems this PR changed the previous default value in Rails 7.2 for popular adapters like Sidekiq or Resque, and Solid Queue too (not popular but with the same behaviour 😅 ), if the user hadn't touched anything. I realised this because of rails/solid_queue#409. In Rails 7.2, we had the following logic:
So, if someone didn't touch In any case this is ok, for Solid Queue it meant updating the README, that was based on the previous behaviour, but I thought I'd double-check just in case it wasn't intentional. |
|
@rafaelfranca This change is missing from the Active Job 8.0 changelog. This is a breaking change for apps using Sidekiq and relying on the adapter default, as now jobs are no longer queued after transaction commit by default. |
|
It was intended. We decided to not let the adapter decide it #52659 (comment). I realize that broke the behavior for adapter that thought they were in charge. I'll add to the release notes. But now that I think about it, not having this config being global kinda of defeats the automatic enqueuing of jobs after transaction feature. Maybe I misunderstood @dhh's comment #52659 (comment). @dhh do you think we should allow this a global config and always defer enqueuing of jobs to after the commit? meaning default behavior is |
|
Yes, by default, all jobs should enqueue after the commit. And this should be a setting that Active Job controls. And it should also be downplayed as something people might want to change. I don't think people should change this. In fact, if we didn't have the history of going back and forth on it, I wouldn't even have made it a setting. |
|
Ok. I think we can do that. For 8.0 the ship has sailed since |
|
@rafaelfranca @dhh something to consider as this config is removed is how it should interact with gems that provide their own active jobs. For example the
Now I think about it, the same issue applies, for example, to the Active Storage built in jobs. We are working around this with an initializer: Rails.application.config.after_initialize do
ActiveSupport.on_load(:active_job) do
ActiveJob::Base.enqueue_after_transaction_commit = true
end
endAnd a test: test "enqueue_after_transaction_commit is true" do
# https://github.com/rails/rails/pull/53375#issuecomment-2632770426
assert_same true, ApplicationJob.enqueue_after_transaction_commit
assert_same true, Noticed::ApplicationJob.enqueue_after_transaction_commit
assert_same true, ActiveStorage::AnalyzeJob.enqueue_after_transaction_commit
end... but at this point it kinda feels like a global config. (Presumably the initializer can be removed in Rails 8.1 if my understanding of the above comments is correct. And the test can be removed when I have confidence this won't change anymore 😆 ) |
…abetically in all test SQL and create_table definitions
|
@dhh (and everyone here)
I’ve opened a follow-up PR that proposes a concrete patch to move Rails toward that default behavior: The change sets I’d appreciate your thoughts on whether this approach aligns with the intended behavior. Thanks as always for maintaining Rails. |
Also change the configuration to be a boolean instead of a symbol.
The value of this setting isn't delegated to the queue adapter anymore, since the behavior that this setting controls is too dangerous to leave this change of behavior as something that users don't control.
Fixes #52675.