I want to apply a parallel and concurrent process for each raw of a table, and each process must take a unique raw.
I have a mysql table with a default Null field value named trigger. At the begining of each parallel process, the process selects a Null raw with:
SELECT table_id from table where trigger is Null limit 1
and then immediatly, in a second request, the process do an update :
UPDATE table set trigger = 1 where table_id = [#previous_select_table_id]
With that process , normally, each raw will be different for each process. The issue I have, is sometimes, during the time between the two requests (select and update), two or more processes can select the same empty raw because they don't have the time to update the raw and set value. Do you have any ideas how to do a select and an update in the same query or other ideas, to be sure a raw can't be selected during the same time ? I use python. Thanks a lot !