Mysql Dense Write Problem

  mysql, question

Dear bosses, I recently encountered a problem. First of all, my program logic is as follows:

//1. Obtain records according to equipment number
$row = $this->user->get($did);


//create new user


//login in with this uid


//2.login the server

return $info.

The client logic is that if the second step fails to log in, a request will be sent to the server for one second until the server logs in normally.
However, I found that occasionally a device number writes multiple records (the time interval between the generation of these records is 1 second), which is definitely not possible according to logic. I doubt whether it is because there are too many requests during that time and mysql process is stuck, so the program has been returning to empty and then has been generating new records. however, it doesn’t make sense. since it is stuck, how can it write successfully? I would appreciate some advice from experts.

What ideas can we exchange?