Skip to content
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

how to handle inconsistency? #522

Closed
saiqulhaq-hh opened this issue Oct 25, 2022 · 5 comments
Closed

how to handle inconsistency? #522

saiqulhaq-hh opened this issue Oct 25, 2022 · 5 comments

Comments

@saiqulhaq-hh
Copy link

I am having many issues when using .fetch method

IdentityCache::RecordNotFound: An error occurred on xxx

I could solve it by overriding the .fetch method with

module IdentityCache
  module WithPrimaryIndex
    module ClassMethods
      def fetch(id, includes: nil)
        fetch_by_id(id, includes: includes) || find(id)
      end
    end
  end
end

which is not a correct way

I am just wondering do you have this issue too in Shopify?

@raivil
Copy link

raivil commented Dec 19, 2022

@saiqulhaq-hh what kind of issues are you facing?
I'm having issues with IDC as well, as described at #525

@driv3r
Copy link
Contributor

driv3r commented Jan 17, 2023

@saiqulhaq-hh IDC will try to load the record from cache (if enabled) and if it's missing it will pull it from DB, so when IDC raises RecordNotFound error , it couldn't find it in DB either.

@dylanahsmith
Copy link
Contributor

IDC will cache the absence of a record, so this could just be a cache inconsistency, which is an expected occurrence when cache invalidations fails. I think we failed to document this, so I opened #529 to update the caveats to mention this symptom of lost cache invalidations:

IdentityCache also caches the absence of database values (e.g. to avoid performance problems when it is destroyed), so lost cache invalidations can also result in that value continuing to remain absent. As such, avoid sending the id of an uncommitted database record to another process (e.g. queuing it to a background job), since that could result in an attempt to read the record by its id before it has been created. A cache invalidation will still be attempted when the record is created, but that could be lost.

@dylanahsmith
Copy link
Contributor

Also, we would ideally have a way to opt-out of nil caching (as discussed in #501)

@saiqulhaq-hh
Copy link
Author

thanks @dylanahsmith
the readme doc looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants