mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #14720 from nvanbenschoten/nvanbenschoten/clarifyUnstableStableTo
This commit is contained in:
commit
910b81b153
@ -75,17 +75,21 @@ func (u *unstable) maybeTerm(i uint64) (uint64, bool) {
|
|||||||
func (u *unstable) stableTo(i, t uint64) {
|
func (u *unstable) stableTo(i, t uint64) {
|
||||||
gt, ok := u.maybeTerm(i)
|
gt, ok := u.maybeTerm(i)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
// Unstable entry missing. Ignore.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if i < u.offset {
|
||||||
|
// Index matched unstable snapshot, not unstable entry. Ignore.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gt != t {
|
||||||
|
// Term mismatch between unstable entry and specified entry. Ignore.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// if i < offset, term is matched with the snapshot
|
|
||||||
// only update the unstable entries if term is matched with
|
|
||||||
// an unstable entry.
|
|
||||||
if gt == t && i >= u.offset {
|
|
||||||
u.entries = u.entries[i+1-u.offset:]
|
u.entries = u.entries[i+1-u.offset:]
|
||||||
u.offset = i + 1
|
u.offset = i + 1
|
||||||
u.shrinkEntriesArray()
|
u.shrinkEntriesArray()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// shrinkEntriesArray discards the underlying array used by the entries slice
|
// shrinkEntriesArray discards the underlying array used by the entries slice
|
||||||
// if most of it isn't being used. This avoids holding references to a bunch of
|
// if most of it isn't being used. This avoids holding references to a bunch of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user