I have a list of jobs for multiple users stored in a MySQL table. I'm currently planning to do the following in the client app:
- Ask MySQL server for jobs that are not allocated to anybody.
- Mark the first job allocated to myself.
But the problem is, if 2 users somehow get the same list of "unallocated" jobs, they will both mark the same job as allocated. So how to manage such a situation, and ensure that each user gets only a unique unallocated job?
I'm trying to avoid using stored procs since I want all code within the app if possible.