I have a table with millions of rows:
id | info | uid
The uid is null by default. I want to select 10 rows and assign them to a uid, but I want to avoid any potential concurrency issues. So I think the only way to do that is to somehow select 10 rows based on certain criteria, lock those rows and then make my changes before unlocking them.
Is there a way to do row-locking in MySQL and PHP? Or is there some other way I can gaurantee that this doesnt happen:
- user a queries the table where uid is null
- finds row 1
- user b queries the table where uid is null
- finds row 1
- user a process row and sets it back to null
- user b process row and sets it back to null
See my problem?