mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix Issue #15549, unbounded memory growth when saving records that have any after_create callbacks (or any associations, which makes after_create callbacks for you)
This commit is contained in:
parent
c7f22c7794
commit
045c77c1bc
1 changed files with 3 additions and 2 deletions
|
@ -489,7 +489,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def has_transactional_callbacks? # :nodoc:
|
||||
!_rollback_callbacks.empty? || !_commit_callbacks.empty? || !_create_callbacks.empty?
|
||||
!_rollback_callbacks.empty? || !_commit_callbacks.empty?
|
||||
end
|
||||
|
||||
# Updates the attributes on this particular ActiveRecord object so that
|
||||
|
@ -514,6 +514,8 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def update_attributes_from_transaction_state(transaction_state, depth)
|
||||
@reflects_state = [false] if depth == 0
|
||||
|
||||
if transaction_state && transaction_state.finalized? && !has_transactional_callbacks?
|
||||
unless @reflects_state[depth]
|
||||
restore_transaction_record_state if transaction_state.rolledback?
|
||||
|
@ -550,7 +552,6 @@ module ActiveRecord
|
|||
@txn = nil
|
||||
@_start_transaction_state = {}
|
||||
@transaction_state = nil
|
||||
@reflects_state = [false]
|
||||
end
|
||||
|
||||
def initialize_internals_callback
|
||||
|
|
Loading…
Reference in a new issue