2023-09-15 23:29:30 +08:00
|
|
|
* Clarify the backoff strategy for the recommended `:wait` option when retrying jobs
|
|
|
|
|
|
|
|
`wait: :exponentially_longer` is waiting polynomially longer, so it is now recommended to use `wait: :polynomially_longer` to keep the same behavior.
|
|
|
|
|
|
|
|
*Victor Mours*
|
|
|
|
|
2023-09-13 08:36:01 +08:00
|
|
|
## Rails 7.1.0.beta1 (September 13, 2023) ##
|
|
|
|
|
2023-04-05 09:05:16 +08:00
|
|
|
* Fix Active Job log message to correctly report a job failed to enqueue
|
|
|
|
when the adapter raises an `ActiveJob::EnqueueError`.
|
|
|
|
|
|
|
|
*Ben Sheldon*
|
|
|
|
|
2023-08-22 01:39:03 +08:00
|
|
|
* Add `after_discard` method.
|
2023-05-02 03:50:31 +08:00
|
|
|
|
|
|
|
This method lets job authors define a block which will be run when a job is about to be discarded. For example:
|
|
|
|
|
|
|
|
```ruby
|
2023-09-07 02:03:58 +08:00
|
|
|
class AfterDiscardJob < ActiveJob::Base
|
|
|
|
after_discard do |job, exception|
|
|
|
|
Rails.logger.info("#{job.class} raised an exception: #{exception}")
|
|
|
|
end
|
2023-05-02 03:50:31 +08:00
|
|
|
|
2023-09-07 02:03:58 +08:00
|
|
|
def perform
|
|
|
|
raise StandardError
|
2023-05-02 03:50:31 +08:00
|
|
|
end
|
2023-09-07 02:03:58 +08:00
|
|
|
end
|
2023-05-02 03:50:31 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
The above job will run the block passed to `after_discard` after the job is discarded. The exception will
|
|
|
|
still be raised after the block has been run.
|
|
|
|
|
|
|
|
*Rob Cardy*
|
|
|
|
|
2022-01-26 23:07:12 +08:00
|
|
|
* Fix deserialization of ActiveSupport::Duration
|
|
|
|
|
|
|
|
Previously, a deserialized Duration would return an array from Duration#parts.
|
|
|
|
It will now return a hash just like a regular Duration.
|
|
|
|
|
|
|
|
This also fixes an error when trying to add or subtract from a deserialized Duration
|
|
|
|
(eg `duration + 1.year`).
|
|
|
|
|
|
|
|
*Jonathan del Strother*
|
|
|
|
|
2023-06-28 17:43:41 +08:00
|
|
|
* `perform_enqueued_jobs` is now compatible with all Active Job adapters
|
|
|
|
|
|
|
|
This means that methods that depend on it, like Action Mailer's `assert_emails`,
|
|
|
|
will work correctly even if the test adapter is not used.
|
|
|
|
|
|
|
|
*Alex Ghiculescu*
|
|
|
|
|
2023-04-21 01:21:26 +08:00
|
|
|
* Allow queue adapters to provide a custom name by implementing `queue_adapter_name`
|
|
|
|
|
|
|
|
*Sander Verdonschot*
|
|
|
|
|
2023-04-02 08:20:10 +08:00
|
|
|
* Log background job enqueue callers
|
|
|
|
|
|
|
|
Add `verbose_enqueue_logs` configuration option to display the caller
|
|
|
|
of background job enqueue in the log to help with debugging.
|
|
|
|
|
|
|
|
Example log line:
|
|
|
|
|
|
|
|
```
|
|
|
|
Enqueued AvatarThumbnailsJob (Job ID: ab528951-41fb-4c48-9129-3171791c27d6) to Sidekiq(default) with arguments: 1092412064
|
|
|
|
↳ app/models/user.rb:421:in `generate_avatar_thumbnails'
|
|
|
|
```
|
|
|
|
|
|
|
|
Enabled in development only for new and upgraded applications. Not recommended for use
|
|
|
|
in the production environment since it relies on Ruby's `Kernel#caller` which is fairly slow.
|
|
|
|
|
|
|
|
*fatkodima*
|
|
|
|
|
2023-03-22 14:52:28 +08:00
|
|
|
* Set `provider_job_id` for Backburner jobs
|
|
|
|
|
|
|
|
*Cameron Matheson*
|
|
|
|
|
2022-11-03 04:53:10 +08:00
|
|
|
* Add `perform_all_later` to enqueue multiple jobs at once
|
|
|
|
|
|
|
|
This adds the ability to bulk enqueue jobs, without running callbacks, by
|
|
|
|
passing multiple jobs or an array of jobs. For example:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0))
|
|
|
|
|
|
|
|
user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) }
|
|
|
|
ActiveJob.perform_all_later(user_jobs)
|
|
|
|
```
|
|
|
|
|
|
|
|
This can greatly reduce the number of round-trips to the queue datastore.
|
|
|
|
For queue adapters that do not implement the new `enqueue_all` method, we
|
2023-06-25 17:26:20 +08:00
|
|
|
fall back to enqueuing jobs individually. The Sidekiq adapter implements
|
2022-11-03 04:53:10 +08:00
|
|
|
`enqueue_all` with `push_bulk`.
|
|
|
|
|
|
|
|
This method does not use the existing `enqueue.active_job` event, but adds a
|
|
|
|
new event `enqueue_all.active_job`.
|
|
|
|
|
|
|
|
*Sander Verdonschot*
|
|
|
|
|
2022-10-20 04:33:51 +08:00
|
|
|
* Don't double log the `job` when using `ActiveRecord::QueryLog`
|
|
|
|
|
|
|
|
Previously if you set `config.active_record.query_log_tags` to an array that included
|
|
|
|
`:job`, the job name would get logged twice. This bug has been fixed.
|
|
|
|
|
|
|
|
*Alex Ghiculescu*
|
|
|
|
|
2022-09-20 19:49:16 +08:00
|
|
|
* Add support for Sidekiq's transaction-aware client
|
|
|
|
|
|
|
|
*Jonathan del Strother*
|
|
|
|
|
2022-09-10 23:11:44 +08:00
|
|
|
* Remove QueAdapter from Active Job.
|
|
|
|
|
|
|
|
After maintaining Active Job QueAdapter by Rails and Que side
|
|
|
|
to support Ruby 3 keyword arguments and options provided as top level keywords,
|
|
|
|
it is quite difficult to maintain it this way.
|
|
|
|
|
|
|
|
Active Job Que adapter can be included in the future version of que gem itself.
|
|
|
|
|
|
|
|
*Yasuo Honda*
|
|
|
|
|
Add ActiveJob::Serializers::BigDecimalSerializer
Previously, BigDecimal was listed as not needing a serializer. However,
when used with an adapter storing the job arguments as JSON, it would get
serialized as a simple String, resulting in deserialization also producing
a String (instead of a BigDecimal).
By using a serializer, we ensure the round trip is safe.
During upgrade deployments of applications with multiple replicas making use of
BigDecimal job arguments with a queue adapter serializing to JSON, there exists
a possible race condition, whereby a "new" replica enqueues a job with an
argument serialized using `BigDecimalSerializer`, and an "old" replica fails to
deserialize it (as it does not have `BigDecimalSerializer`).
Therefore, to ensure safe upgrades, serialization will not use
`BigDecimalSerializer` until `config.active_job.use_big_decimal_serializer` is
enabled, which can be done safely after successful deployment of Rails 7.1.
This option will be removed in Rails 7.2, when it will become the default.
2022-07-18 01:17:30 +08:00
|
|
|
* Fix BigDecimal (de)serialization for adapters using JSON.
|
|
|
|
|
|
|
|
Previously, BigDecimal was listed as not needing a serializer. However,
|
|
|
|
when used with an adapter storing the job arguments as JSON, it would get
|
|
|
|
serialized as a simple String, resulting in deserialization also producing
|
|
|
|
a String (instead of a BigDecimal).
|
|
|
|
|
|
|
|
By using a serializer, we ensure the round trip is safe.
|
|
|
|
|
|
|
|
To ensure applications using BigDecimal job arguments are not subject to
|
|
|
|
race conditions during deployment (where a replica running a version of
|
|
|
|
Rails without BigDecimalSerializer fails to deserialize an argument
|
|
|
|
serialized with it), `ActiveJob.use_big_decimal_serializer` is disabled by
|
|
|
|
default, and can be set to true in a following deployment..
|
|
|
|
|
|
|
|
*Sam Bostock*
|
|
|
|
|
2022-07-13 06:15:43 +08:00
|
|
|
* Preserve full-precision `enqueued_at` timestamps for serialized jobs,
|
|
|
|
allowing more accurate reporting of how long a job spent waiting in the
|
|
|
|
queue before it was performed.
|
|
|
|
|
|
|
|
Retains IS08601 format compatibility.
|
|
|
|
|
|
|
|
*Jeremy Daer*
|
|
|
|
|
2022-07-06 08:42:37 +08:00
|
|
|
* Add `--parent` option to job generator to specify parent class of job.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
`bin/rails g job process_payment --parent=payment_job` generates:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
class ProcessPaymentJob < PaymentJob
|
|
|
|
# ...
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2022-06-11 06:45:22 +08:00
|
|
|
* Add more detailed description to job generator.
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2020-08-16 23:01:12 +08:00
|
|
|
* `perform.active_job` notification payloads now include `:db_runtime`, which
|
|
|
|
is the total time (in ms) taken by database queries while performing a job.
|
|
|
|
This value can be used to better understand how a job's time is spent.
|
|
|
|
|
|
|
|
*Jonathan Hefner*
|
|
|
|
|
2022-08-29 14:32:31 +08:00
|
|
|
* Update `ActiveJob::QueueAdapters::QueAdapter` to remove deprecation warning.
|
2022-03-21 20:39:02 +08:00
|
|
|
|
|
|
|
Remove a deprecation warning introduced in que 1.2 to prepare for changes in
|
|
|
|
que 2.0 necessary for Ruby 3 compatibility.
|
|
|
|
|
|
|
|
*Damir Zekic* and *Adis Hasovic*
|
|
|
|
|
2022-02-12 16:54:41 +08:00
|
|
|
* Add missing `bigdecimal` require in `ActiveJob::Arguments`
|
|
|
|
|
|
|
|
Could cause `uninitialized constant ActiveJob::Arguments::BigDecimal (NameError)`
|
|
|
|
when loading Active Job in isolation.
|
|
|
|
|
|
|
|
*Jean Boussier*
|
|
|
|
|
2021-08-22 16:47:01 +08:00
|
|
|
* Allow testing `discard_on/retry_on ActiveJob::DeserializationError`
|
2021-11-20 06:04:55 +08:00
|
|
|
|
2021-08-22 16:47:01 +08:00
|
|
|
Previously in `perform_enqueued_jobs`, `deserialize_arguments_if_needed`
|
|
|
|
was called before calling `perform_now`. When a record no longer exists
|
|
|
|
and is serialized using GlobalID this led to raising
|
|
|
|
an `ActiveJob::DeserializationError` before reaching `perform_now` call.
|
2022-05-26 07:48:46 +08:00
|
|
|
This behavior makes difficult testing the job `discard_on/retry_on` logic.
|
2021-08-22 16:47:01 +08:00
|
|
|
|
|
|
|
Now `deserialize_arguments_if_needed` call is postponed to when `perform_now`
|
|
|
|
is called.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
class UpdateUserJob < ActiveJob::Base
|
|
|
|
discard_on ActiveJob::DeserializationError
|
|
|
|
|
|
|
|
def perform(user)
|
|
|
|
# ...
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# In the test
|
|
|
|
User.destroy_all
|
|
|
|
assert_nothing_raised do
|
|
|
|
perform_enqueued_jobs only: UpdateUserJob
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
*Jacopo Beschi*
|
2021-11-20 06:04:55 +08:00
|
|
|
|
2021-12-07 23:52:30 +08:00
|
|
|
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activejob/CHANGELOG.md) for previous changes.
|