How to avoid race condition if multiple clients choose in MySQL?
I have a task_id table that has two columns:
`tid`:task id, `state`:0:unfinished,1:processing,2:finished
Easy if I only use one client (Perl script): pick one
task id, update it to
, process it and update to
in a loop.
But I am planning on using multiple clients to accomplish this task. There is a possibility that two clients are taking the entry at the same time, how to avoid it?
source to share