On the problem of mysql concurrent repeated insertion

1. The scenario in which the problem occurs
1. Network delay, or use the FD tool to simulate requests

sql
select time form order where uid="15" order by time desc limit 0 br > if (current time-time < 15) {
exit (do not request frequently);
}

INSERT INTO order (time, uid,...) VALUES (value 1, value 2.)

there is also a CURL request
if (CURL request succeeded) {

} else {

}

problem:
in case of concurrency or network instability.. There is a repeated insertion.. Failed to intercept; not intercepted. Still entered curl

.

need to intercept before entering the curl request

Apr.21,2022

Don't let your form be submitted repeatedly


the processing of repeated requests depends mainly on your conditional requirements.

if you restrict the same client to the same request at the same time. The simple thing to do is to put the client request identity in the cache.
and check whether there is already an access request before each visit, and return the request if so. On the contrary, it will be dealt with normally.

the same client, network layer, and database can all do the same similar measures to avoid repeated insertion.


the repeated submission of the form should be controlled first, judge when writing, skip and write to the log

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-1c2091c-3285d.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-1c2091c-3285d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?