Datastore applied

24 views
Skip to first unread message

Phil McDonnell

unread,
Dec 6, 2011, 9:26:06 PM12/6/11
to google-a...@googlegroups.com
I'm in java on GWT app engine and I'm having some intermittent issues where it looks like datastore put() commands are not being reflected by subsequent get() calls.  From my reading I thought this was not possible.  Am I mistaken?

Here's what I'm doing...

// STATE A
Entity x = ...
datastore.put(x);
// STATE B
... 
x = ... some new values ... 
datastore.put(x);
// STATE C
... 
datastore.get(keyOfX);

The final get() sometimes returns an x of state C and sometimes it returns an x of state B.  Any idea why this happens?  I'm assuming it's some sort of concurrency thing within my app, but perhaps I've misunderstood the datastore guarantees?  Should the get() always get an x from state C?

Thanks,
Phil

Jeff Schnitzer

unread,
Dec 6, 2011, 10:17:16 PM12/6/11
to google-a...@googlegroups.com
Are you executing in a transaction?  get()s in a transaction always show the entity "frozen in time" as of the start of the transaction.  Even if you put() a change, get() will show the old value until the transaction is committed.

Jeff

--
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.



--
We are the 20%

Phil McDonnell

unread,
Dec 6, 2011, 10:25:35 PM12/6/11
to google-a...@googlegroups.com
No, the puts/gets are executing normally.  I did try wrapping the puts() in a transaction, but it didn't help.  If I wrap just the get() in a transaction should that somehow trigger the puts() to apply?  Is there some way to wait?

Thanks so much,
Phil

YuchTing

unread,
Dec 6, 2011, 9:31:03 PM12/6/11
to google-a...@googlegroups.com
check http://code.google.com/status/appengine for GAE current status.

Is GAE datastore abnomal?

Phil McDonnell

unread,
Dec 7, 2011, 2:31:51 AM12/7/11
to google-a...@googlegroups.com
As it turns out, I was using a Query and not a get().  I believe Queries might not be guaranteed to return everything that has been put(), right?  That would explain the inconsistencies I've been seeing if this is the case.  Can someone confirm this?

Thanks,
Phil

To post to this group, send email to google-appengine@googlegroups.com.

To unsubscribe from this group, send email to

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 google-appengine@googlegroups.com.
To unsubscribe from this group, send email to google-appengine+unsubscribe@googlegroups.com.

Francois Masurel

unread,
Dec 7, 2011, 10:18:04 AM12/7/11
to google-a...@googlegroups.com
Try to use the same transaction for your gets, it will be ok then.

François

Jeff Schnitzer

unread,
Dec 7, 2011, 10:47:39 AM12/7/11
to google-a...@googlegroups.com
Assuming you are on the HRD, that is correct.  Queries (without an ancestor() restriction) are always eventually consistent and may return stale data.

Jeff

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.



--
We are the 20%

Reply all
Reply to author
Forward
0 new messages