raft 的一个约束问题 If leaderCommit > commitIndex, set commitIndex = min(leaderCommit, index of last new entry)

在论文中,AppendEntries RPC的规则5,是这样的:
If leaderCommit > commitIndex, set commitIndex = min(leaderCommit, index of last new entry)
这里的index of last new entry,我不知道改怎么理解。
我看了网上很多人的实现,都是:
if args.LeaderCommit > rf.commitIndex {
rf.commitIndex = min(args.LeaderCommit, len(rf.log)-1)
}
但是6.824助教的学生指南里面写了这段话:
The min in the final step (#5) of AppendEntries is necessary, and it needs to be computed with the index of the last new entry. It is not sufficient to simply have the function that applies things from your log between lastApplied and commitIndex stop when it reaches the end of your log. This is because you may have entries in your log that differ from the leader’s log after the entries that the leader sent you (which all match the ones in your log). Because #3 dictates that you only truncate your log if you have conflicting entries, those won’t be removed, and if leaderCommit is beyond the entries the leader sent you, you may apply incorrect entries.
所以上面那个实现方式是正确的吗,follow有没有可能apply与leader不一致的log?

这条学生指南不就是在说第 5 点吗?
为什么要取最小值?因为 commitIndex 是可能超过当期追加日志中的日志的(因为超过,而不发生冲突,所有没有被覆盖或者删除),那么这时候如果 commitIndex 超过它的话,就会将错误的状态应用到状态机。