Project

General

Profile

Bug #12241

Counter cache update didn't pick up changes from after_commit callback

Added by Tomer Brisker almost 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

`after_commit` callback doesn't have a `changes` hash, instead need to use `previous_changes` hash.


Related issues

Related to Foreman - Bug #10133: Massive db deadlocks in postgres from hosts_counter updates with counter_cache_fix.rbClosed2015-04-14

Associated revisions

Revision 565dc8e5 (diff)
Added by Tomer Brisker almost 4 years ago

Fixes #12241 - Correct counter_cache deadlock fix

Previous fix had a bug - in `:after_commit` `self.changes` is empty, and the
changes are in `self.previous_changes`. Also this only needs to run on
update.
This commit adds tests to make sure cached_counters continue to work
correctly in the future.

Revision 7f66b46b (diff)
Added by Tomer Brisker over 3 years ago

Fixes #12241 - Correct counter_cache deadlock fix

Previous fix had a bug - in `:after_commit` `self.changes` is empty, and the
changes are in `self.previous_changes`. Also this only needs to run on
update.
This commit adds tests to make sure cached_counters continue to work
correctly in the future.

(cherry picked from commit 565dc8e5292346cafe48601396c83c54cc582f00)

History

#1 Updated by Tomer Brisker almost 4 years ago

  • Related to Bug #10133: Massive db deadlocks in postgres from hosts_counter updates with counter_cache_fix.rb added

#2 Updated by The Foreman Bot almost 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2839 added
  • Pull request deleted ()

#3 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 104

#4 Updated by Dominic Cleal almost 4 years ago

  • Subject changed from fix for #10133 was incorrect to Counter cache update didn't pick up changes from after_commit callback
  • Category changed from Dashboard to Rails

#5 Updated by Anonymous almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF