-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache busting doesn't bubble up in some cases without eagerloading #389
Comments
Your example in the ancestor-invalidation-failing branch uses |
You're absolutely right, turns out that wasn't the issue, it was around some hooks not being installed (ie Thanks for the quick feedback! |
Oh, that sounds like it could be an issue with the lazy expiration hook installation. Maybe that isn't working properly for deeply embedded associations |
Yeah, I ended up debugging quite a bit more and that's what it is. The fix shouldn't be too bad but I need to figure out how to test and not impact performance – not something I can realistically dedicate to in the next couple days :/ |
I took some time to put together what I think is a real failing test: |
Been thinking about it some more and the only solution I can come up with is to recursively load all associated models so their hooks are loaded, which means loading everything. This will likely have a significant development perf impact for big codebases. And even thant is only guaranteed to work when relationships are defined on both sides. |
I don't think we need to load everything, since parent expiration is only needed for has_one and has_many connections, which requires a corresponding belongs_to association. So only the belongs_to associations need to be loaded on a call to Unfortunately, that would still end up loading more than needed, so would have a performance impact on development. If that becomes a concern, it would be possible to make it more precise by being more explicit about which models embed that model to reduce what is loaded. However, I would prefer to avoid adding that complexity until we know it is needed, since it isn't clear to me that it would be significant enough to be a problem. |
Given the following classes:
when saving an instance of
C
,B
gets removed from the cache, but notA
. Thus,B#fetch_c
returns the latest version butA#fetch_bs
return a stale collection.I could reproduce this scenario as a failing test: https://github.com/Shopify/identity_cache/compare/ancestor-invalidation-failing
Am I missing something or is this a bug?
The text was updated successfully, but these errors were encountered: