I have a task_id table which has two columns:
`tid`:task id,
`state`:0:unfinished,1:processing,2:finished
It’s easy if I use only one client(Perl script): fetch one unfinished task id,update it to processing, process it, and update it to finished in a loop.
But I’m planning to use several clients to do the task. There is a chance that two clients fetch a record in the same time, how to avoid it?
If your mysql table’s engine is INNODB then it locks that particular row while updating the table record so other request will not be conflicted with previous update.