Simultaneous SELECT and UPDATE - Lock to prevent concurrency problems

So, I work in a high concurrency environment. What I want to do is select a row from the mysql database based on a specific property, and then, as soon as I get this row, I want to set the “blocked” flag on the row so that I can do some work in php (which it might take some time) and then unlock it when I finish. What is the best way to do this to prevent concurrency issues that occur when you have a separate SELECT and UPDATE command?

+7
source share
2 answers
+2
source

Does this FOR UPDATE method actually lock the line immediately and unlock it only after the same PHP session has executed the UPDATE command on the same line?

0
source

All Articles