Commit Graph

10 Commits

Author SHA1 Message Date
Rafael França
a13b135258
Revert "Run ActiveRecord -> ActiveJob integration tests in CI" 2021-06-15 11:19:04 -04:00
Alex Ghiculescu
3837a5c0c9 Run ActiveRecord -> ActiveJob integration tests in CI 2021-06-15 09:17:41 -05:00
Ashik Salman
8e1b191b37 Updated abbreviation for single table inheritance. 2021-04-16 11:53:05 +05:30
Ryuta Kamizono
043184d903 Fix end alignment 2021-03-21 15:46:36 +09:00
Rafael França
a04b301522
Merge pull request #41093 from gwincr11/action-job-transactions
Make destroy async transactional
2021-02-01 19:11:26 -05:00
Rafael Mendonça França
48a7760823
Refactoring the code to not add methods to all models
Only models that need to use the `:destroy_async` feature
need those methods so it is better to not add to all models.
2021-02-01 23:26:04 +00:00
Cory Gwin
8e4c0ddc34 add new module to handle queueing of jobs to enqueue after commit is successful 2021-01-27 15:33:25 -05:00
Cory Gwin
cfcd904436 Make destroy async transactional
Motivation:
  - A active record rollback could occur while enqueuing a job in this
    case the job would enqueue even though the database deletion
    rolledback putting things in a funky state. So this adds some
    functionality to ensure that deletions are not queued until after
    the db transaction has been commited.

Related Issues:
  - Sort of related to https://github.com/rails/rails/issues/26045

Changes:
  - add some syntatic sugar to transactions to make enqueueing a job a
    little better experience, this really hooks into the after destroy
    hook on the transaction.
  - Setup async destroy on associations to not enqueue until after a
    transaction has been committed.
2021-01-12 09:45:03 -05:00
Muhammad Usman
095878c6e4 Handle STI models for has_many dependent: :destroy_async
Update activerecord/test/activejob/destroy_association_async_test.rb

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
2021-01-06 02:04:23 +01:00
George Claghorn
4cf7559280 Destroy associations in a background job.
Sometimes cascading association deletions can cause timeouts due to
an IO issue. Perhaps a model has associations that are destroyed on
deletion which in turn trigger other deletions and this can continue
down a complex tree. Along this tree you may also hit other IO
operations. Such deep deletions can lead to server timeouts while
awaiting completion and really the user may not notice all the
changes on their side immediately making them wait unnecesarially or
worse causing a timeout during the operation.

We now allow associations supporting the `dependent:` key to take `:destroy_async`,
which schedules a background job to destroy associations.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
Co-authored-by: Cory Gwin @gwincr11 <gwincr11@github.com>
2020-09-24 14:24:15 -04:00