diff options
author | Will Bryant <will.bryant@gmail.com> | 2014-09-03 00:12:52 +1200 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-02-01 14:01:54 -0800 |
commit | 045c77c1bc8f9acdc7efe34ba7af59acfe6f955f (patch) | |
tree | 1c64d440e39c27e4cbf3683c50f3e9a2b29aeade /activerecord/lib | |
parent | c7f22c779403f2275341245564c092442fc6e0f0 (diff) | |
download | rails-045c77c1bc8f9acdc7efe34ba7af59acfe6f955f.tar.gz rails-045c77c1bc8f9acdc7efe34ba7af59acfe6f955f.tar.bz2 rails-045c77c1bc8f9acdc7efe34ba7af59acfe6f955f.zip |
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)
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 6ed5dd0bfa..c1eaa4f49b 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -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 |