当前位置:网站首页>Summary of process and principle of solution to concurrency problem (form repeated submission problem)
Summary of process and principle of solution to concurrency problem (form repeated submission problem)
2022-04-22 16:31:00 【qq_ seventeen million twenty-three thousand nine hundred and se】
With the help of databases
insert Use unique index update Use Optimism lock version Edition method
This kind of efficiency depends on the ability of database hardware in large amount of data and high concurrency , For non core business
Optimistic lock mode 1: version control + The spin *( Where does spin reflect )*
Considering that the probability of these update conflicts is not high . Here, we use database optimistic lock to realize
The principle is based on CAS, Compare and exchange data , If the discovery has been updated , Direct update failed
Then add spin ( Self circulation return ) Then update , Until success . Optimism lies in our belief that the probability of conflict is low
If it happens , Just use a cheap mechanism to quickly find . Fast failure .
Let's discuss how to implement it , Database table GoodsSale Add a new line data_version To record the updated version number of the data . The new table structure is as follows :

GoodsSaleDao#uodateCount Corresponding mapper Of SQL Statement , The data is updated at the same time data_version = data_version+!, Execute this sql At this time, the row lock has been applied to the data , So this data_version Add 1 The operation of is atomic operation

1. Row lock and table lock
stay mysql Of InnoDB The engine supports row locking , And Oracle Different ,mysql The row locks are loaded through the index , That is, the row lock is added to the row of the index response , If the corresponding SQL The statement doesn't follow the index , It will scan the whole table , Row locks cannot be implemented , Instead, the table lock .
Mysql In the field of innodb The storage engine supports row level locking ,innodb The row lock of is realized by locking the index entries , This means that only when retrieving data through index conditions ,innodb To use the row lock , Otherwise, use the watch lock .
Update the statement based on the current data (UPDATE user set name=‘11111’ where account=‘1’), This condition field account No Index added , So the data table is locked .
版权声明
本文为[qq_ seventeen million twenty-three thousand nine hundred and se]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221625141166.html
边栏推荐
- window10安装STEP7 Micro/Win V4.0 SP9,安装完后每次开机都提示Assertion Program:pniopcac.exe File
- 2022-4-21 [webrtc application] source code analysis of yangrtc / metartc open source library (III)
- C language insertion sort
- 查询表中distinct 数据 数量 count mysql oracle 取指定条数
- 如何关闭联想杀毒Plus
- Hx711 weight sensor wiring
- 国美新动作“真选”“严选”赋能 多维度护航品质消费
- 漫谈同源策略(SOP)和跨域资源共享(CORS)
- 蓝桥杯练习017
- Transforme结构:位置编码 | Transformer Architecture: The Positional Encoding
猜你喜欢

An error is reported in the automatic database backup, indicating that SQLServerAgent is not currently running, so it cannot be notified of this operation.

Dynamically drag the width of two divs

产业调研:厂商视角看国产数据库发展趋势
![[b01lers2020]Life on Mars](/img/4c/c21f74153d6a668349d39f54e95e26.png)
[b01lers2020]Life on Mars

Solidworks斜参考面

Redis optimization series (I) building redis master-slave based on docker

RT-Thread Studio 工作区编码设置为UTF-8
![2022-4-21 [webrtc application] source code analysis of yangrtc / metartc open source library (III)](/img/a5/2e984494455d5a5127964fb49457d7.png)
2022-4-21 [webrtc application] source code analysis of yangrtc / metartc open source library (III)

Algorithm:实现LDA的Gibbs Gauss采样(绘制多图subplot)

Calculation method of numerator and denominator of system driven by stepping servo motor for rotation angle control
随机推荐
C ODBC loads the files of one folder into the blob column of Oracle database and downloads the blob column to another folder
渗透测试&网络&CTF面试题整理
Test life | less than 2 years after graduation, 0 experience and won the 30W annual salary of a well-known Internet enterprise. How did he do it?
解决并发问题方案流程及原理总结(表单重复提交问题)
SolidWorks insert socket head cap screw
【csnote】范式
MINIUSB pin interface pin definition
Experiment 4: KNN, naive Bayes of data mining
TCP/IP协议之四TCP协议(上)—理论+实践给你讲清楚
Huawei machine test questions -- hj54 expression evaluation
蓝桥杯练习014
HX711重量传感器接线
坚持做正确的事情
实验三 FFT及其在卷积计算和谱分析中的应用
Where is the dimension association table of Flink SQL? 800W dimension table
UI测试有哪些功能问题?-泽众云测试
Random talk on homology strategy (SOP) and cross domain resource sharing (CORS)
80386汇编_寄存器 & 寻址方式介绍
MySQL日志
An error is reported in the automatic database backup, indicating that SQLServerAgent is not currently running, so it cannot be notified of this operation.