知识卡片

支付系统案例卡 · 1971.o.1.b.4.d.1.c.4.a.1.a.1

锁定采购单守住额度上限

理解等级:高级

针对[[采购单行项并发突破额度]],把采购单及行项作为同一聚合,在修改时锁定整张采购单,第二个编辑者必须等前一事务完成并看到最新总额,超额改动便不能直接保存。这让审批上限在提交时得到检查。代价是同一采购单的不同人也要排队;若常有多人并行编辑大型采购单,锁范围会影响工作效率。这里是原书采购单示例,不代表所有系统必须使用悲观锁。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第44章《原书第06章|Aggregates》(源文件:_epub-src/0321125215_ch06lev1sec1.html;图6.8) - 结论依据:原文明确整单加锁可防止该例中的违规保存,但也指出多人同时编辑大型采购单时会产生等待。 - 原始内容:If instead we had locked an entire PO at a time, the problem would have been prevented. ... The program will not allow this transaction to be saved until Amanda has resolved the problem, perhaps by raising the limit or by eliminating a guitar. ... But if multiple people typically work simultaneously on different line items of a large PO, then this locking will get cumbersome.