Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

feat: fault tolerance for global caches - #560

Merged
andrewsg merged 2 commits into
googleapis:masterfrom
chrisrossi:feat-557
Oct 22, 2020
Merged

feat: fault tolerance for global caches#560
andrewsg merged 2 commits into
googleapis:masterfrom
chrisrossi:feat-557

Conversation

@chrisrossi

Copy link
Copy Markdown
Contributor

Closes #557

@chrisrossi chrisrossi added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 15, 2020
@chrisrossi
chrisrossi requested a review from cguardia October 15, 2020 15:31
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 15, 2020
@chrisrossi

Copy link
Copy Markdown
Contributor Author

WIP This shows the basic strategy. Has been tested with real world application. Default is to tolerance when doing "lookup" operations, and intolerance when doing anything else, which requires cache invalidation. User may override defaults with big caveat that clients may retrieve stale data from cache if strict_write is set to False.

Still need tests to go. Still considering whether or not to add retry functionality for the cache calls. Sharing now for potential early feedback.

@chrisrossi chrisrossi removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 18, 2020
@chrisrossi

Copy link
Copy Markdown
Contributor Author

This is ready for review and possible merge. I had it about 95% done on Friday.

@cguardia cguardia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Thanks!

Comment thread google/cloud/ndb/global_cache.py Outdated
the application. If :data:`True`, connection errors during write will be
raised as exceptions in the application. Because write operations involve
cache invalidation, setting this to :data:`False` may allow other clients to
retreive stale data from the cache. If there is a connection error, an

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve

Comment thread google/cloud/ndb/global_cache.py Outdated
exception in the application. If :data:`True`, connection errors during
write will be raised as exceptions in the application. Because write
operations involve cache invalidation, setting this to :data:`False` may
allow other clients to retreive stale data from the cache. If there is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve

Comment thread google/cloud/ndb/global_cache.py Outdated
the application. If :data:`True`, connection errors during write will be
raised as exceptions in the application. Because write operations involve
cache invalidation, setting this to :data:`False` may allow other clients to
retreive stale data from the cache. If there is a connection error, an

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve

Comment thread google/cloud/ndb/global_cache.py Outdated
exception in the application. If :data:`True`, connection errors during
write will be raised as exceptions in the application. Because write
operations involve cache invalidation, setting this to :data:`False` may
allow other clients to retreive stale data from the cache. If there is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrieve

@andrewsg andrewsg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just one question before I merge. Thanks!

_LOCK_TIME = 32
_PREFIX = b"NDB30"

warnings.filterwarnings("always", module=__name__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I have better context here, what is this intended to filter out and why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually unfiltering. The default, for warnings, is to log them once and don't log any duplicates. This is overriding that default so the warnings are shown every time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Thank you

@andrewsg
andrewsg merged commit 8ab8ee0 into googleapis:master Oct 22, 2020
Attributes:
strict_read (bool): If :data:`True`, transient errors that occur as part of a
entity lookup operation will be logged as warnings but not raised to the
application layer.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That description seems reversed. Same for strict_write below.

@cguardia

Copy link
Copy Markdown
Contributor

@anssih Thanks for noticing this. It has already been fixed in #565, but has not yet been merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Database actions should be tolerant of cache (redis or memcache) connection failures

4 participants