I don't know if this will help (depends on some specifics of your data model),
but I've found that using a query to get a list of entities, followed by a get
to actually get the data, is a good workaround for many eventual consistency
issues.
Here's snippet of code that provides the functionality I use:
class HRModel(db.Model):
@classmethod
def gql_keys(cls, query_string, *args, **kwds):
return db.GqlQuery('SELECT __key__ FROM %s %s' % (cls.kind(),
query_string), *args, **kwds)
@classmethod
def gql_ids(cls, query_string, *args, **kwds):
return [x.id() for x in db.GqlQuery('SELECT __key__ FROM %s %s' %
(cls.kind(), query_string), *args, **kwds)]
@classmethod
def gql_with_get(cls, query_string, *args, **kwds):
return filter(None, db.get(db.GqlQuery('SELECT __key__ FROM %s %s' %
(cls.kind(), query_string), *args, **kwds)))
The gql_with_get is the magic one. It does a keys-only query, and then does a
get to fetch the entities with those keys. While the query might be
out-of-date, the get is guaranteed to be consistent with the most recent writes.
If an entity returned by the possibly stale query results is deleted, the
filter will clean that out.
If an entity should have been returned but was not, then you won't pick it up.
That is only a problem for brand-new entities, and I don't have a solution for
that. For already-existing entities, you could just query for near-miss leader,
and then filter out the scores that made the query, but aren't justified by the
actual state of the leader board after the get. For example, if your leader
board has 100 entries, query for the top 150, and then re-sort the results and
take the top 100 of those.
Make sense?
-Joshua
On Aug 1, 2012, at 2:27 PM, Richard <[email protected]> wrote:
> Summary so far:
>
> I have a massive multiplayer Android game. It has tight timings.
> "Sometimes" (at the same time of day.. when load is lowest), GAE will do a
> put() and 5-10 seconds later when I do a query all to create leaderboards for
> that game round, I get stale results..... for some of the entries. This is
> because the put() has completed, but not the (internal) commit().
>
> This started 5 days ago. Moving to PULL queues did not work, because entries
> sometimes take at 5+ seconds to 'show up' in the pull queue.
>
> On Wednesday, August 1, 2012 2:20:37 PM UTC-4, Joshua Smith wrote:
> I haven't been following this thread to closely. Can you summarize the
> problem as you understand it at this point?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/r4yYvSgNJFwJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.