I have a long mysql queue. I have 1 worker script that processes each queue.
but as this worker is running, the database may be updated or get new row inserts.
an example worker script
get_current_queue = SELECT from queue...
while(get_current_queue) {
update_current_row_from_queue "processing"
//some cpu intensive processing here that takes varying amount of time.
}
the problem is that the worker script takes different amount of time depending on how long the queue at the given time is, and how long each cpu processing takes (converting videos for ex).
so when i run another worker script while the first one is running, the queue not yet marked as "processing" in the queue database by the first worker, will fall onto the second worker's todo list.
I dont know how to approach this problem.
when a worker runs, i need some way to mark this batch so only this worker will run it.
and while this is running, after new rows are inserted, if i choose to start another worker, it can work.