The way we did it (in MYSQL) was "UPDATE tasks SET processid=<unique id for the queue consumer task> WHERE processid IS NULL ORDER BY taskid LIMIT 1" and then look for processid to find your task. I guess the LIMIT on UPDATE might be an mysql extension? Then if your task crashes or dies you can look for invalid processids and do cleanup
>>kalleb+(OP)
Our initial did that too but generating a unique was removed soon after as had expire in there anyways for retries as I mentioned and that is enough.