We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问,为什么您的代码中持久化了这两个变量呢?
func (rf *Raft) getPersistData() []byte { w := new(bytes.Buffer) e := labgob.NewEncoder(w) e.Encode(rf.term) e.Encode(rf.voteFor) e.Encode(rf.commitIndex) e.Encode(rf.lastSnapshotIndex) e.Encode(rf.lastSnapshotTerm) e.Encode(rf.logEntries) data := w.Bytes() return data }
其实我赞成您的这个做法,但在论文中并没有提到需要持久化这两个变量,尤其是lastApplied。 如果没有持久化lastApplied,节点在reboot之后,应该会根据commitIndex更新lastApplied,这样便会重复apply在reboot之前的entry。 难道是因为apply的状态本来就是不稳定的?也就是数据都是在内存中?🤣而不是apply到磁盘里边?
The text was updated successfully, but these errors were encountered:
重复 apply 是有问题的, 所以要持久化记录之前的点; apply term 和 记录 lastApplied 应该看成是原子的
Sorry, something went wrong.
明白了,谢谢!
No branches or pull requests
请问,为什么您的代码中持久化了这两个变量呢?
其实我赞成您的这个做法,但在论文中并没有提到需要持久化这两个变量,尤其是lastApplied。
如果没有持久化lastApplied,节点在reboot之后,应该会根据commitIndex更新lastApplied,这样便会重复apply在reboot之前的entry。
难道是因为apply的状态本来就是不稳定的?也就是数据都是在内存中?🤣而不是apply到磁盘里边?
The text was updated successfully, but these errors were encountered: