Skip to content

Add active_record.destroy_association_async_batch_size configuration#44617

Merged
jhawthorn merged 1 commit intorails:mainfrom
nholden:destroy-async-batch
Mar 9, 2022
Merged

Add active_record.destroy_association_async_batch_size configuration#44617
jhawthorn merged 1 commit intorails:mainfrom
nholden:destroy-async-batch

Conversation

@nholden
Copy link
Contributor

@nholden nholden commented Mar 4, 2022

This allows applications to specify the maximum number of records that will be destroyed in a single background job by the dependent: :destroy_async association option. By default, the current behavior will remain the same: when a parent record is destroyed, all dependent records will be destroyed in a single background job. If the number of dependent records is greater than this configuration, the records will be destroyed in multiple background jobs.

At GitHub, we have a custom method for destroying associated records in the background that we'd like to replace with
dependent: :destroy_async. Some associations have a large number of dependent records, and our infrastructure requires that background jobs complete quickly, so we limit the maximum number of dependent records destroyed in a single background job and enqueue additional jobs when the number of records exceeds that limit.

This allows applications to specify the maximum number of records that
will be destroyed in a single background job by the `dependent:
:destroy_async` association option. By default, the current behavior
will remain the same: when a parent record is destroyed, all dependent
records will be destroyed in a single background job. If the number of
dependent records is greater than this configuration, the records will
be destroyed in multiple background jobs.

At GitHub, we have a custom method for destroying associated records
in the background that we'd like to replace with
`dependent: :destroy_async`. Some associations have a large number of
dependent records, and our infrastructure requires that background jobs
complete quickly, so we limit the maximum number of dependent records
destroyed in a single background job and enqueue additional jobs when
the number of records exceeds that limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants