When you need to ensure other threads are not being able to read table while you are updating record.
To implement reading and incrementing the counter, first perform a locking read of the counter using
FOR UPDATE, and then increment the counter.
The preceding description is merely an example of how
SELECT ... FOR UPDATE works. In MySQL, the specific task of generating a unique identifier actually can be accomplished using only a single access to the table:
SELECT statement merely retrieves the identifier information (specific to the current connection). It does not access any table.
Contents are from https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html