Comments (13)
仔细思考了下,这里存在的问题跟 #15 类似,issue 中描述的场景确实可能出现,出现了两个分割的 majority: (A, B) 和 (B, C),又凑巧出现写入极少或者没有的情况, A无法及时发现 C成为了新的 leader,在 1个 hearbteat 周期内,C又刚好写入了新日志,这样 A 会认为自己是 leader,而出现了 stale read,应当在 preVote 加入租约有效期的判断,来避免 C 成为新的 leader。
感谢分析。
from sofa-jraft.
赞一个,你们的回复速度很快
from sofa-jraft.
可以参考paxos made live给出的方案, 让follewer在lease周期内不接受选举产生新的leader就可以了
from sofa-jraft.
In our implementation, all replicas implicitly grant a lease to the master of the previous Paxos instance
and refuse to process Paxos messages from any other replica while the lease is held. The master maintains
a shorter timeout for the lease than the replicas – this protects the system against clock drift. The master
periodically submits a dummy “heartbeat” value to Paxos to refresh its lease.
from sofa-jraft.
@pifuant 我的疑问是sofa-jraft目前的实现似乎没有保证这个
from sofa-jraft.
@PFZheng 我也似乎没看到相关处理
from sofa-jraft.
@PFZheng @pifuant 其实有处理的,只是不是采用时间判断的方式,而是使用定时器来避开,请参考 handleElectionTimeout
实现,这是定时器定期调用,间隔就是 election timeout。preVote 的发起只能在 lastLeaderTimestamp 过期的情况下才会发起。follower 保证在没有收到更新的 leader 请求后才会发起 preVote。
leader 和 follower 之间心跳间隔是 election timeout 的 1/10。除了定期心跳之外,所有复制请求也会更新 lastLeaderTimestamp
。
from sofa-jraft.
仔细思考了下,这里存在的问题跟 #15 类似,issue 中描述的场景确实可能出现,出现了两个分割的 majority: (A, B) 和 (B, C),又凑巧出现写入极少或者没有的情况, A无法及时发现 C成为了新的 leader,在 1个 hearbteat 周期内,C又刚好写入了新日志,这样 A 会认为自己是 leader,而出现了 stale read,应当在 preVote 加入租约有效期的判断,来避免 C 成为新的 leader。
感谢分析。
看了这个,的确可以用同一方法来解决😊。另外,我建议可以另外提供一个lease timeout的参数。
from sofa-jraft.
this.checkReplicator(peer);
if (nowMs - replicatorGroup.getLastRpcSendTimestamp(peer) <= options.getElectionTimeoutMs()) {
aliveCount++;
continue;
}
deadNodes.addPeer(peer);
这里的replicatorGroup.getLastRpcSendTimestamp(peer)是不是应该判断下是已经收到peer response确认过的,而不单单只是SendTimestamp。
from sofa-jraft.
@pifuant 他是 Replicator 里的 lastRpcSendTimestamp,每次在 rpc response 返回后更新的。名字可能误导你了。
from sofa-jraft.
@killme2008 thx, 由于时钟偏移, 判断lease有效时, 是不是用小于options.getElectionTimeoutMs()的某个值代替options.getElectionTimeoutMs()更好一点呢
from sofa-jraft.
@pifuant 因为 heartbeat 的周期是 electionTimeout 的十分之一,这个小于getElectionTimeoutMs多少的值
如何设置都不会完全合理,保持目前这个判断可以接受了。
from sofa-jraft.
这个 bug 已在 v1.2.4中发布解决,先关闭了
from sofa-jraft.
Related Issues (20)
- 希望尽快适配高版本jdk,目前尝试改动源代码升级到jdk21.启动集群正常,但是CliService工具异常,提示Connection is null when do check! HOT 5
- 能否对新加入的参与者提供自认证机制。或者预留自认证机制接口,让用户自己实现 HOT 15
- 对于rheakv分为:kv数据存储目录以及raft log存储目录。但是参与者之间数据同步处理的是日志目录。那kv数据目录怎么同步了 HOT 1
- 请教个问题:任务应用到多数派状态机决定条件是怎样的???对于kv系统是否因为这个导致数据丢失。 HOT 5
- 请教个问题:有没有配置或者一种机制(比如多长时间后),对于离线的节点,leader心跳检测临时抛弃 HOT 5
- 节点重启有机率出现No locks available,不知道这正常吗?? HOT 3
- 能否通过spi开放集群成员合法性校验,同时允许成员携带额外信息(用户自行实现成员合法性校验时使用) HOT 13
- AssertionError in AppendEntriesRequestProcessor HOT 1
- Commit index may be smaller than snapshot index HOT 1
- 请教问题:jraft的log目录会不会随着系统运行时间而无限增加,有没有清空策略 HOT 4
- 请教个问题:应用到多数派方式是不是可能导致数据丢失。 HOT 1
- fowlloe
- 集群重启时,follower启动失败
- what's the best way to re-add an existing node to the cluster in EKS
- How to verify the legitimacy of a member? HOT 2
- ReadIndex frequently times out. HOT 4
- Unrecycled RPC threads cause OOM HOT 2
- Deadlock on configuration application in NodeImpl when disruptors are full HOT 9
- 压测性能耗时较高,200多ms HOT 2
- 在这种情况下是不是会出现死锁? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sofa-jraft.