Shopify / Shopify/identity_cache
Cache isn't invalidated by a counter cache update
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 174
- Avg merge
- 13m
- Merged PRs (30d)
- 3
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100