On Wednesday, 26 December 2012 19:26:35 UTC+13, Mahron wrote:
>
> Hi, 
>
> I would like to know what happens if two simultaneous lease_tasks are 
> called, is it possible that both get returned the same tasks ? or is 
> there something to prevent that scenario ? 
>

The recommendation from Google about pull queues is "Tasks should be 
idempotent, so even if a task lease expires and another client leases the 
task, performing the same task twice should not cause an error."

With push queues (standard task queues) there is also no guarantee that a 
task will not be executed more than once so probably the same caveat is 
true when you manage the queue yourself.

How likely is this?  The push queue docs say: "App Engine's Task Queue API 
is designed to only invoke a given task once; however, it is possible in 
exceptional circumstances that a task may execute multiple times (such as 
in the unlikely case of major system failure). Thus, your code must ensure 
that there are no harmful side-effects of repeated execution."

However I have seen it happen more frequently than "major system failures". 
 I have a task chain that uses named tasks (can only be added once) and 
roughly 1 / 500,000 tasks gets repeated. 

If you truly need to ensure tasks execute only once you can give each a 
serial number (in a task chain increment the value for each new task) and 
at the start of your task do a transactional "check and increment" 
operation on the datastore.

-- 
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/-/WqFUEfLAinoJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to