-
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
Mark IDC fetched records as read_only #274
Comments
All excellent points, I agree! It's tempting to let records from the DB miss path be writable since they are technically up to date but I think determinism and sanity is sooo much more important. Good call. |
I think @daniellaniyo can do this after she finishes with the unchain-ability of resutls |
In a test suite that uses transactions for isolation, |
Thanks for pointing that out, since we have a |
That would be great! Ping me if you want me to test it first - we also use multiple databases in production. |
@daniellaniyo I think we have a branch where @eugeneius can test now right? |
@camilo Yes! Actually the tests could be carried out on the current master branch and setting Also note that we haven't included the |
Thanks @camilo / @daniellaniyo - but the I was working on a similar problem recently (preventing background jobs from being enqueued inside a transaction) - I've shared the approach I took there in #293. |
I just ran our application's test suite against master with my patch from #293 applied. There were a bunch of failures, but it looks like they're all legitimate cases of fetching a record from the cache and updating it. I have some work to do before I can think about testing in production 😬 |
I will close this issue, since this is the default behaviour since a while ago. |
cc @airhorns, @camilo
This was attempted before in #85, which gives a good explanation for the problem:
One thing I think we should do differently from the pull request, is that records returned from IDC methods when
IdentityCache.should_cache?
returns false should not be marked as read-only. The problem with marking those records as read-only is that it prevents us from sharing code to use for reading and writing, e.g. calculating some aggregation for a confirmation page which should be consistent with the calculation for the operation itself.On the other hand, records fetched from the database on a cache miss when
IdentityCache.should_cache?
returns true should be marked as read-only. This way code that does the wrong thing will fail deterministically, rather than passing on a cache miss and failing on a cache hit.We might also want to consider making this behaviour configurable, so that we don't get blocked on Shopify needed to be updated to work with this new behaviour, which was probably the main reason that the previous PR didn't get finished and merged. That way we can at least have identity cache do the right thing by default on the next release with breaking changes.
The text was updated successfully, but these errors were encountered: