Mysql select for update - it is not locking the target rows. How do I make sure it does?
问题 So the syntax for select for update is something like SELECT * //1st query FROM test WHERE id = 4 FOR UPDATE; UPDATE test //2nd query SET parent = 100 WHERE id = 4; I am guessing the locking part is the first line. So when the first set of queries executes, I should not be able to select and modify the row with id = 4 (it is primary key by the way). However, I am still able to select row with id = 4 before I update anything, meaning another thread could probably come in and try to select and