Shopify / Shopify/identity_cache

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.

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

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.