Reputation: 1711
I am having the following problem. I am now using the low-level google datastore API rather than JDO, that way I should be in a better position to see exactly what is happening in my code. I am writing an entity to the datastore and shortly thereafter reading it from the datastore using Jetty and eclipse. Sometimes the written entity is not being read. This would be a real problem if it were to happen in production code. I am using the 2.0 RC2 API.
I have tried this several times, sometimes the entity is retrieved from the datastore and sometimes it is not. I am doing a simple query on the datastore just after committing a write transaction.
(If I run the code through the debugger things run slow enough that the entity has a chance of being read back on the second pass).
Any help with this issue would be greatly appreciated,
Regards,
Upvotes: 3
Views: 1505
Reputation: 2111
The development server has the same consistency guarantees as the High Replication datastore on the live server. A "global" query uses an index that is only guaranteed to be eventually consistent with writes. To perform a query with strongly consistent guarantees, the query must be limited to an entity group, using an "ancestor" key.
A typical technique is to group data specific to a single user in a group, so the user can see changes to queries limited to the user's group with strong consistency guarantees. Another technique is to use fancier client logic to update the client's local view as soon as the change is submitted, so the user sees the change in the UI immediately while the update to the global index is in progress.
See the docs on queries and transactions.
Upvotes: 5