I have a MySql database linked to my website, that has a table with a task list (columns are separated by "/" below), i.e.:
task1 / doTask1.sh / todo
task2 / doTask2.sh / done
task3 / doTask3.sh / todo
task4 / doTask4.sh / todo
etc...
On every request to my website, I want the "todo" tasks to be executed and then marked as "done" by the server. The task can only be executed once. But here comes the problem.
What if:
User A selects the tasks that are marked as "todo". doTask1.sh executes and is marked as done, triggered by request from user A. User B selects the tasks that are marked as "todo" (task3 and task3 only, since task1 is done). doTask3.sh executes and is marked as done, triggered by request from user A. doTask3.sh executes again, triggered by request from user B. Same for doTask4.sh.
Can this happen using PHP/Nginx/MySql, due to simultaneous DB connections? If yes, how can this problem be bypassed/avoided?
In this example, I used doTaskx.sh to simplify the situation. In reality, this column would contain a description of the task and the PHP script powering my website would execute a task depending on that description.