lni / dragonboat

A feature complete and high performance multi-group Raft library in Go.
Apache License 2.0
5.09k stars 542 forks source link

Why ReadIndex re-write previous request's index? #370

Closed shimingyah closed 2 months ago

shimingyah commented 2 months ago

Notice the following code:

                   for _, v := range cs {
            if v.index > s.index {
                panic("v.index > s.index is unexpected")
            }
            // re-write the index for extra safety.
            // we don't know what we don't know.
            v.index = s.index
        }

Implementation of etcd, no need to re-write index. https://github.com/etcd-io/raft/blob/main/read_only.go#L81

Is there some kind of BUG? Can we not re-write index?

lni commented 2 months ago

index of the log is never rewritten.

as explained by the comments, code above is for extra protections. I don't think there is any bug here.