在“Designing Data-Intensive Applications - CHAPTER 5 Replication - Leaderless Replication - Limitations of Quorum Consistency”中,它说:
However, even with w + r > n, there are likely to be edge cases where stale values are returned. These depend on the implementation, but possible scenarios include:
- ...
- If a write succeeded on some replicas but failed on others (for example because the disks on some nodes are full), and overall succeeded on fewer than w replicas, it is not rolled back on the replicas where it succeeded. This means that if a write was reported as failed, subsequent reads may or may not return the value from that write.
- ...
它说后续的读可能会返回写入失败的值,是类似下面这样的情况吗?
假设 n 为 5,w 和 r 都是 3 。键 k 的初始化值为 1 。
client 1 执行 set k = k + 1 写,这个写只在两个副本( replica 1 和 replica 2 )成功,所以是失败的。
client 2 读取键 k 的值,它在 replica 1 和 replica 2 中读取到 2,而在 replica 3 读取到 1,所以 client 2 会被告知键 k 的值为 2 。
我的疑问
- 上面的理解对吗?如果是这样子,不就相当于读取到了错误的值吗?
- 复制是怎么操作的呢?按照道理最后所有副本里面的值应该是 1 才对,但是具体是怎么操作的呢? replica 1 和 replica 2 是怎么知道应该使用 1 来覆写 2 的呢? replica 3-5 又是怎么知道 2 是失败的写,从而继续保留 1 的呢?