知识卡片
采购单行项并发突破额度
原书采购单教学例子要求行项总额不超过审批上限。上限1000、初始总额700时,两人分别编辑不同的行项,各自视图都算出900;若只锁各自行项而忽略对方未提交的改动,保存后总额变成1100,采购单级规则被破坏。根因是校验范围覆盖整张采购单,锁与事务边界却只覆盖单个行项。对应方案见[[锁定采购单守住额度上限]]。这不是实际支付交易结果。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Aggregates · 查看原书依据
Everything looks fine to both users and to their software because they ignore changes to other parts of the database that happen during the transaction, and neither locked line item is involved in the other user's change.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第44章《原书第06章|Aggregates》(源文件:_epub-src/0321125215_ch06lev1sec1.html;图6.4–6.7)
- 结论依据:图6.4给出采购单总额不超过审批上限的规则,图6.5–6.7依次给出700、两个900视图和最终1100;正文说明两个行项分别锁定无法保护整单不变量。
- 原始内容:Everything looks fine to both users and to their software because they ignore changes to other parts of the database that happen during the transaction, and neither locked line item is involved in the other user's change. ... After both users have saved their changes, a PO is stored in the database that violates the invariant of the domain model.