--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
Note that ancestor queries are also strongly consistent. This is
detailed in the docs:
http://code.google.com/appengine/docs/java/datastore/hr/#Data_Storage_Options_Compared
Robert
Queries and gets inside a transaction are guaranteed to see a single, consistent snapshot of the Datastore as of the beginning of the transaction. Entities and index rows in the transaction's entity group are fully updated so that queries return the complete, correct set of result entities, without the false positives or false negatives described in Transaction Isolation that can occur in queries outside of transactions.
--
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/-/w-_g6OeGwFcJ.
The "without the false positives or false negatives" comment led me to believe that as long as I did my query within a transaction I would see results that were previously added within a different transaction (except in the case of an unapplied write - which requires manual admin intervention). For example, in my app I need to do some post-processing after a new item is added. I do this by enqueuing a transactional task. That task runs a query that should return the item previously added. Is there no way to ensure my query will include the item - e.g. avoid the false negative. If not, any suggestions on how to implement this sort of post processing once the item's index do get updated? My post processing queries lots of different data and stitches together a bunch of statistics and statistical summaries.
Jeff,Thanks for the reply! You've really, really helped. I understand that a task will have to create a transaction and that it doesn't run in the context of the transaction that may have enqueued it. A re-phrasing of my question:Request 1 -> txn.begin() -> add entity "statistic" to "account" -> commit() ... where the commit enqueues the next request/taskRequest 2 (task) -> txn.begin() -> query "account" for all "statistics" -> txn.commit()It sounds like what you're saying is that as long as "account" and "statistic" are in the same entity group, then I'll see the added person. If they're not in the same entity group, then it'll be eventually consistent, right? In our case, we're using JDO and the relationship between statistic and account is modeled as a "Key" field, but they aren't in the same entity group. In "Request 2" we simply query by kind "statistic" for all statistics with a filter for the current account. We don't get any error like "ancestor required in transaction".
Last question: does the use of the transaction in Request 2 make any difference?
As for our app, you can think of it as a finance app with credits and debits and statistics like "total spent", "average spent", etc. And we roll up stats so we have a hierarchy of summaries for different periods: weeks, months, years, all years. We currently kick off tasks to recalculate stat summaries whenever a credit or debit is added. Call it "near-realtime". When the user navigates to the "all-years" page we've likely recalculated the hierarchy of stat summaries. We don't really want to wait for them to request this page to go try and calculate all the summaries because it could be a long wait. I also wasn't too fond of having a cron job every minute looking for changes, but maybe that's what I need to do.
An app can perform a query during a transaction, but only if it includes an ancestor filter. (You can actually perform a query without an ancestor filter, but the results won't reflect any particular transactionally consistent state).
I feel like I am keeping you from real work :) I do appreciate it.