When the user clicks the submit button twice in a row, if no measures are taken, there will be two pieces of data in the data.
Solution: check when inserting database. Insert a distributed lock on the database in the code. Use redis as the object of the lock. After locking, make a judgment. The short rule is to look up a piece of data from the database. If the data does not exist, insert it and generate an ID in the database. If it exists (insert the second data), take out this data and update it. In this way, the problem of repeated insertion can be solved.
Existing problems: it is not clear whether it is a duplicate submission or a user’s update operation
Read More:
- Breaking the web page to prevent copying
- Idea can’t submit code to GitHub when using git — too much code / file leads to submission failure
- GitHub desktop submission errors and Solutions
- Prevent flashback after running code in VC 6.0
- The solution of duplicate entry ‘for key’ primary ‘when inserting data in MySQL
- E11000 duplicate key error collection in mongodb
- Txt import MySQL: error 1062 (23000): duplicate entry ‘0’ for key ‘primary’
- Vue + antd writes wrong output statement, resulting in no error report and no form submission
- Lambda set to map duplicate key error solution
- Solution of duplicate entry ‘value’ for key ‘field name’ in MySQL
- Duplicate entry ‘787192513’ for key ‘primary’
- Duplicate keys detected: ‘XXXX’. This may cause an update error. Solution
- mysql Error Code: 1022. Can’t write; duplicate key in table `xxx`
- Dbsql occurs when configuring SAP ATC during SCI check_DUPLICATE_KEY_ERROR
- [Vue warn]: Duplicate keys detected: ‘‘. This may cause an update error.
- Proteus simulation duplicate part reference error
- Duplicate keys detected: ‘***‘. This may cause an update error
- Vue warn: duplicate keys detected: ‘1’. This may cause an update error
- pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: anjuke.ershoufang index
- Removing duplicate lines from Linux shell files