#0304 · 方法
两个人同时点会怎样
假设这段代码被两个请求同时执行,按时间线推演最坏的交错顺序:哪里会读到旧值,哪里会重复写入,哪里会丢更新。每个问题给出时间线示意和修法(锁、唯一约束、原子操作或幂等键)。
[代码]
Assume two requests run this code at the same moment. Walk through the worst interleaving on a timeline: where a stale value is read, where a write happens twice, where an update is lost. For each, show the timeline and a fix (lock, unique constraint, atomic op, or idempotency key).
[code]
小杜
已贴 1,040 张上墙共收到 0 个章