ndb and consistency: Why is happening this behavior in a query without a parent

萝らか妹 提交于 2019-12-04 10:58:02

Ancestor queries operate in the same entity group (and therefore physical proximity) and are strongly consistent.

In test 1 the HRD might not see the put() since it is eventually consistent due to it's distributed nature.

In test 2 the HRD has enough time to become consistent so you see the entity in the query.

In test 3 you place it in the same entity group so it is strongly consistent.

Q: Why not have everything in the same entity group?
A: GAE can't distribute a massive dataset unless there are a bunch of entity groups (then they can push them out to tons of different servers). Entity groups should be just as large as you need them to be and no larger (G sometimes uses the example of putting a users "messages" under a User object). Also, since writing to a member of an entity group locks the whole group you face write speed limitations (like 1 write/sec if I remember, Alfred has a talk on it).

Q: My get() didn't get the object, isn't is supposed to?
A: No, only get's by key are strongly consistent, you did a query().get() which is really just shorthand for LIMIT 1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!