In a new web site I’m building, I may have to create a page that queries the MySQL database for a value in a particular record, increments that value, then queries the database again to update the record with the new value.
My question is: Is there a danger of a race condition here if this page is loaded by two users simultaneously? (i.e., user A’s first query reads the value, then user B’s first query reads it, they both increment, and the final value represents only a single increment after both insert queries) Or do PHP and MySQL already have built-in measures to prevent this?
If it is a danger, what’s a possible solution? And how high does the traffic on my site need to be before I should even bother with one?