lichuang / lichuang.github.io

lichuang.github.io
Apache License 2.0
10 stars 0 forks source link

post/20180921-raft/ #2

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Raft算法原理 - codedump

简介 关于Raft算法,有两篇经典的论文,一篇是《In search of an Understandable Consensus Algorithm》,这是作者最开始讲述Raft算法原理的论文,但是这篇论文太

https://codedump.info/post/20180921-raft/

jasonpengdingdingding commented 5 years ago

博主你好!看了你在知乎上的回答。 请教一个问题,看raft大论文+理解论文+实现一个正确的raft c++代码库,假设在每天工作8小时,每周5天的前提下,要多久能完成? 一个月,两个月,三个月等? 近期在评估这项工作的难度,担心掉进一个大坑里面了。

lichuang commented 5 years ago

多久完成取决于你的能力。

至于这个坑是否值得跳,取决于你想这个知识点上面达到的深度。我自己之所以花费很多时间在etcd的raft实现上,原因在于这是raft算法的工业级别实现,同时代码量不算多,对比起来一致性算法在分布式领域的重要性又很高,所以我个人觉得花个几个月时间彻底弄清楚是值得的。

jasonpengdingdingding commented 5 years ago

谢谢,博主,我明白了。

ghost commented 5 years ago

多谢博主提供这么好的资源,写的很好,学习了。

faushine commented 4 years ago

多谢楼主,话说楼主有研究过raft作者写的logcabin吗?性能如何?

shuff1e commented 4 years ago

博主的知乎账号是?我关注下 另外,博主有没有看过hashicorp raft的实现?和etcd raft相比如何?

BryantChang commented 4 years ago

有一个问题问博主 image 在你举例选举新leader后与follower同步日志时,我看从节点C开始,follower返回的最大Index都是11,想问下为啥不是他们当前索引的位置呢

BryantChang commented 4 years ago

image

lichuang commented 4 years ago

上面的同学,现在才看到你的问题,确实那部分有问题,我重新补充了文字和图示。

soooldier commented 3 years ago

请问在“新leader与follower同步数据”章节的case e中,follower是怎么知道最后一个与leader节点数据一致的索引是5呢?

luo2pei4 commented 3 years ago

在“新leader与follower同步数据”章节的case e中,为什么会返回索引5我也不太明白。 follower节点返回索引具体是在raft的handleAppendEntries方法中处理的,通过在maybeAppend方法中调用matchTerm方法判断leader节点传来的同步日志的任期和follower节点的任期不一致,然后返回了0和false。然后调用了raft的send方法,RejectHint属性设置的值为r.raftLog.lastIndex() lastIndex方法调用maybeLastIndex方法先从unstable对象中获取数据,如果unstable中无法获取数据,再从storage中获取。

2585453704 commented 3 years ago

“提交前面任期的日志条目” 这一小节中,对于d1情况,<index:2, term:2>的日志被的日志给覆盖了,但<index:2,term:2>的日志内容对客户端来说已经被成功提交了,但在leader节点中并不存在<index:2, term:2>的日志内容,那这条日志的内容在leader的日志中是不是被丢掉了,客户端去leader中读时,会不会读不到<index:2, term:2>所做的变更