File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -212,8 +212,9 @@ START TRANSACTION;
212
212
COMMIT;
213
213
```
214
214
215
- 2 . 如果不允许超卖的话,则在事务的过程中,注意事务还未结束,检查quantity是小于0 , 小于0则说明超卖了,立即回滚事务,撤销当前的订单。
215
+ 2 . 如果不允许超卖的话,则在事务的过程中,注意事务还未结束,检查quantity是否小于0 , 小于0则说明超卖了,立即回滚事务,撤销当前的订单。
216
216
217
+ ```
217
218
select quantity from inventory_test where product_id=1
218
219
219
220
if quantity <0 {
@@ -222,7 +223,7 @@ if quantity <0 {
222
223
else {
223
224
COMMIT;
224
225
}
225
-
226
+ ```
226
227
227
228
### 6.3 总结
228
229
Original file line number Diff line number Diff line change 15
15
16
16
### 2.2 CAP理论
17
17
18
- ## 3. 什么是[ Sage模式 ] (http://microservices.io/ patterns/data/saga.html)?
18
+ ## 3. 什么是[ Saga模式 ] (http://microservices.io/ patterns/data/saga.html)?
19
19
20
20
基于异步消息,协调一系列本地事务,以保证数据最终一次性。
21
21
32
32
33
33
## 如何实现“隔离性”?
34
34
35
- * 在跨服务,没有数据库事务的情况,我们在微服务系统要面临:
35
+ 在跨服务,没有数据库事务的情况,我们在微服务系统要面临:
36
36
37
37
* 更新丢失
38
38
* 脏读
39
39
* 不可重复读
40
40
41
- * 解决方法
41
+ 解决方法
42
42
43
43
* 语义化版本锁(Semantic lock)— 应用层锁
44
44
* 可交换更新(Commutative updates)—Design update operations to be executable in any order.
You can’t perform that action at this time.
0 commit comments