What locks will be added by default when mysql innodb engine insert data

I recently did a raffle
everyone can only draw once

I want to insert a record for each lucky draw request, and then read the first record for comparison to determine whether he is drawing the lottery for the first time, delete the useless record if not for the first time, and return an error

will there be a large number of innsert delete operations
will these two operations lock the table?

May.11,2021

intercept with redis cache, and then use ON DUPLICATE KEY UPDATE to see the number of rows returned. The returned result


innodb engine's insert,update,delete operation adds exclusive locks (row-level locks) to the operation data. No other transaction can operate on this row of data at this time.


1. I feel so troublesome that
2.InnoDB is a row lock


in addition to @ start2004's answer, you can also put the request of each role into a separate queue, so that you can query first and then insert

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34997-e477.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34997-e477.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?