Question about Task's Fork Bomb

55 views
Skip to first unread message

BarrenTeam

unread,
Jun 17, 2011, 9:36:55 AM6/17/11
to google-a...@googlegroups.com
Hi, we intensly use tasks in our projects. In our last project we have several problems with task's fork bomb [a task A enqueue a task B then task A fails, when it's retried enqueue again task B and so on]

Suppose to have the following java code:


public class Task1 extends HttpServlet{
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response){

//Datastore reads and writes

Queue queue= QueueFactory.getDefaultQueue();
queue.add(withUrl("/anothertask"));
}
}


We wonder if it's possible that a task's fork bomb can happen in this exemple.
If yes, we would like to know why it can happen.

P.s: In our project we have a lot of code like this above. We have encountered the fork bomb when the task throw a deadlineExceededException or a Datastore Exception

Thanks and sorry for our english :D

Noah McIlraith

unread,
Jun 17, 2011, 9:53:37 AM6/17/11
to google-a...@googlegroups.com
You are supposed to design tasks with some level of idempotency, there are cases where tasks are executed more than once, which will also lead to a fork bomb if not coded properly.

You are supposed to use task names to prevent forks, as task names are unique, so a task can't be inserted twice (blocking a fork bomb).

vlad

unread,
Jun 17, 2011, 4:17:17 PM6/17/11
to google-a...@googlegroups.com
Note that task naming only works for non-transactional tasks. For transactional tasks you have to come up with some kind of Datastore based "run-once" primitive. There is not a standard workaround for transactional task insertion.

BarrenTeam

unread,
Jun 18, 2011, 8:38:49 AM6/18/11
to google-a...@googlegroups.com
Thanks for the answers. I already know the mechanism for avoid bomb fork. But my question is: WHY and HOW can task's bomb fork happen in the code above?

Robert Kluin

unread,
Jun 19, 2011, 11:19:27 AM6/19/11
to google-a...@googlegroups.com
You've not given the code for what ever inserts task1, or the task it inserts.  So the isse could be in several spots.  But from your code, if task1 happens to run twice, either due to a failure or because it decided to run twice, then you get two of the "/anothertask" tasks running. If anothertask also inserts a task... Then you've got a setup with potential problems.

Robert



On Jun 18, 2011, at 5:38, BarrenTeam <barre...@gmail.com> wrote:

Thanks for the answers. I already know the mechanism for avoid bomb fork. But my question is: WHY and HOW can task's bomb fork happen in the code above?

--
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/-/SgzC1m1qMmAJ.
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.
Reply all
Reply to author
Forward
0 new messages