Re: [appengine-java] Task Enqueue in a Transaction

2011-03-22 Thread Tom Gibara
It's my understanding that, with HR, getting an entity by key is only
strongly consistent within a transaction.

If this is wrong, then a significant portion of my own task handling
code may need revisiting...

Perhaps someone who knows more could clarify this.

Tom.

On 21 March 2011 22:10, Simon Knott knott.si...@gmail.com wrote:
 I've got a query about tasks and transactions on a High-replication app that
 I'm hoping someone can help me with.
 I've got the following scenario:
 1) Begin a transaction
 2) Persist an entity
 3) Enqueue a task within the transaction
 4) Commit the transaction
 Within the task, I get the entity via its key and I'm finding that the
 object has yet to be updated in the datastore - it was my belief that
 getting an entity via its key is strongly consistent, so I was quite
 surprised to see that the entity was stale.  Is this result expected?  I've
 got some defensive code in place now which just re-enqueues the task, but I
 wasn't sure whether that was the right approach.
 I originally had the same issue on the MS version of my app, before I
 realised that I needed to enqueue the task within the same transaction to
 ensure the persist had occurred before the task was run.

 --
 You received this message because you are subscribed to the Google Groups
 Google App Engine for Java group.
 To post to this group, send email to google-appengine-java@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Task Enqueue in a Transaction

2011-03-22 Thread Simon Knott
I thought that it was strongly consistent because in the background the 
get-by-key was forced into a transaction and that you didn't have to declare 
it yourself.  If it didn't happen so sporadically, I'd test to see whether 
this fixed the issue!

As you say, if someone could clarify that would be great.  If consistency 
isn't the issue, then it looks to me that the task is being kicked off 
before the transaction is committed.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Task Enqueue in a Transaction

2011-03-22 Thread Jay Young
According to the docs, gets, puts, deletes, and ancestor queries are all 
strongly consistent:
http://code.google.com/appengine/docs/java/datastore/hr/

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Task Enqueue in a Transaction

2011-03-22 Thread Tom Gibara
Thanks for the link, somehow I'd managed to miss that page of
documentation entirely*; it's good to know, though it indicates other
problems for the OP.

I'm not clear on why eventually consistent gets aren't an option, ie.
why all gets are indicated as being strongly consistent. Is this a
direct consequence of replication algorithm used? There are various
places in the code I'm currently developing where dirty gets are
adequate and I'd be happy to see them faster.

* As an aside, I do find the documentation on the datastore feels very
scattered. I'd much prefer sections on the underlying app engine
mechanics with less language specific guidance.

Tom.

On 22 March 2011 17:59, Jay Young jayyoung9...@gmail.com wrote:
 According to the docs, gets, puts, deletes, and ancestor queries are all
 strongly consistent:
 http://code.google.com/appengine/docs/java/datastore/hr/


-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Task Enqueue in a Transaction

2011-03-21 Thread Simon Knott
I've got a query about tasks and transactions on a High-replication app that 
I'm hoping someone can help me with.

I've got the following scenario:
1) Begin a transaction
2) Persist an entity
3) Enqueue a task within the transaction
4) Commit the transaction

Within the task, I get the entity via its key and I'm finding that the 
object has yet to be updated in the datastore - it was my belief that 
getting an entity via its key is strongly consistent, so I was quite 
surprised to see that the entity was stale.  Is this result expected?  I've 
got some defensive code in place now which just re-enqueues the task, but I 
wasn't sure whether that was the right approach.

I originally had the same issue on the MS version of my app, before I 
realised that I needed to enqueue the task within the same transaction to 
ensure the persist had occurred before the task was run.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.