-
Notifications
You must be signed in to change notification settings - Fork 67
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
Consistency issue #751
Comments
Just to make it clearer, the effect of this "deferred" thing is that the |
I have witnessed this problem as well in our software. We rely on this posthook method to keep an elasticsearch in sync. |
We found a cause in the end. When the put would fail, for instance when the entity is larger than 1Mb, the post_hook is still triggered, with a empty key.
|
Hi @anoteboom, and thanks for helping keep this issue alive. The case you encounter, with a failure of the put() is different from ours however, in our case, the put() definitely did occur, and we can later retrieve the entity. Here is an experiment we did when trying to find a workaround:
What happens is we find all 3 traces in our logs, meaning that all 3 cases happen (together with a great majority of successes): (a) reading the entity with a simple get() fails but reading with no_cache succeeds, (b) reading with no_cache fails as well but trying again after 8 seconds succeeds, (c) reading after wait fails as well. We ended up leaving the wait in place since it recovers a number of errors. But it is not always sufficient. |
Hi, Trying to keep alive this unresolved issue (classified as bug so far). Here are two possible ways to mitigate this (not yet tested in a production environment):
None of these is quite satisfactory however. Also, please refer to this "Google Database Products" article, that says this:
The article is undated unfortunately. It would seem that a "lookup by key" (which I understand is a |
Steps to reproduce
On a
_post_put_hook()
, we have a deferred classmethod, via Cloud Tasks, which will do a few additional processing based on the updated or created entity. We passself.key
to the deferred method, and it will then start by retrieving the entity thru a simpleentity = key.get()
.It works most of the time, but it sometimes happens that
key.get()
will return None, although the entity definitely does exist. We tried addinguse_cache=False, use_global_cache=False
to theget()
, but that did not help.We could circumvent the issue by passing the entity itself (self) to the deferred method, but that is not good practice as it might have been modified before the deferred method runs. We could also add some code to sleep a while, then try again (and this actually does work). But I thought firebase in datastore mode now provided strong consistency, and I thought that meant I was certain to be able to read a freshly put entity.
The elapsed time between the
put()
and thedeferred_post_put_hook()
that will do thekey.get()
may vary, but in one example it was around 100ms, and yet theget()
returned None.Code example
The text was updated successfully, but these errors were encountered: