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

Avoid clearing entire cache on transient errors #564

Closed
remko opened this issue Oct 27, 2020 · 5 comments
Closed

Avoid clearing entire cache on transient errors #564

remko opened this issue Oct 27, 2020 · 5 comments
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: question Request for information or clarification. Not an issue.

Comments

@remko
Copy link

remko commented Oct 27, 2020

It seems that google-cloud-ndb now clears the entire global cache (even keys not related to NDB) when any transient error occurs. Since we get transient errors regularly, and since we store other data in our cache, this is problematic for us. I realize a way to avoid this is to use a second Redis instance, but I'd like to avoid this.

Should the entire cache always be cleared on any transient error? I'm guessing limiting it to NDB keys only is too inefficient, but do transient read errors also need to clear a cache? (since I don't think that this can leave the cache in an inconsistent state?)

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label Oct 27, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Oct 28, 2020
@cguardia cguardia added priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Oct 29, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. 🚨 labels Jan 27, 2021
@chrisrossi
Copy link
Contributor

chrisrossi commented Feb 9, 2021

Hi @remko ,

I can see how that would be annoying. Can you use the db parameter when getting your Redis connection in order to have NDB use a different db from your other applications? If using RedisCache.from_environment you can just tack the db, an integer number, to the end of your Redis url:

export REDIS_CACHE_URL=redis://localhost:6379/1

Where 1 is the db. (The default is 0.)

I think that might give you some segmentation where even if NDB has to nuke all of its own data, it doesn't nuke your other applications' data.

@remko
Copy link
Author

remko commented Feb 10, 2021

@chrisrossi How did I not know about this? That indeed sounds like it would solve the most annoying part of my problem, thanks a lot!

It's still a fact that Google-managed Redis instances have a scheduled weekly time where they have many failing connections (at least from GAE), so limiting the number of nukes (e.g. only on write errors, as those would potentially leave the cache in an inconsistent state) would be handy (if this would be correct, of course)

@chrisrossi
Copy link
Contributor

I think the idea is that if there is a known issue with the cache, then it calls into question the validity of the entire contents of the cache. Clearing the whole thing, whether the problem is detected during a read or a write, eliminates any risk of stale data. It's likely that's overkill, but can be hard to guarantee integrity otherwise. We're looking at it now.

@chrisrossi
Copy link
Contributor

Hi @remko ,

Although we haven't specifically addressed this issue, we have with the latest release, shipped a fix that adds retry to cache operations, so it may be that you will be less likely to run into this issue now. If you could use the latest version and let us know how it goes for you, that would really helpful.

Thank you!

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 26, 2021
@remko
Copy link
Author

remko commented Apr 27, 2021

@chrisrossi Thanks! I will still need to separate our databases, so I will give it a shot once this is done too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

5 participants