Cache isn't invalidated by a counter cache update

Open
#362 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rails, ruby
Domain
backend

Research direction

Start in activerecord/lib/active_record/counter_cache.rb, especially the update_counters and reset_counters methods linked in the issue, and trace how IdentityCache observes record changes. Confirm the counter-cache paths do not invalidate the associated record cache, then add coverage showing that both counter updates and resets invalidate it.

Written by the indexing model from the issue text.

Description

The counter_cache belongs_to option is implemented using update_all, which is done on the models update_counters and reset_counters class methods. Because these don't trigger an after_commit callback, we end up not invalidating the cache for the record.

Dominant language
Ruby
Stars
2k
Forks
174
Avg merge
13m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Shopify/identity_cache

All issues in Shopify/identity_cache

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.