Read!

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.

A SELECT ... FOR UPDATE reads the latest available data, setting exclusive locks on each row it reads. Thus, it sets the same locks a searched SQL UPDATE would set on the rows.

The preceding description is merely an example of howSELECT ... 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:

The 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