Consider this situation:
153
id >= 153
Is step 4 safe?
That is, if another request arrives almost exactly at the same time and inserts another 20 records after step 2 above, but before step 4, will there be a race condition?
Yes it will.
Records 21- 40will be blocked by the transaction 2.
21
40
2
1 , 2 .
1
2 , 1 40 ( , 2)
, , DMBS. , , , .
, , , , , . , , mysql . MSSQL.