OK. I'm changing my mind about part of this :)

If the apply_async() call below this fails for any reason (such as not being able to contact the broker), we probably don't want to have the TaskStatus in the DB (since it would just sit in the not started state for eternity). So, I think we should still cut this down to just one query (the $setoninsert one below), but we should perform that query after we can successfully queue the task.

So the part of my mind I've changed is that we should leave the upsert call where it is, but add the tags to it and get rid of this create call. I think that will make everything work correctly.

This also does mean that we don't need to create our own task_id anymore ($setOnInsert takes care of the problem that creating our own task_id was meant to solve). I suggest that we stop making our own task id and just use the one that Celery generates (but we don't have to if you don't want to).