mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: remove duplicate "setAppliedIndex" calls
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
4f754c1850
commit
509cf414f7
@ -155,8 +155,8 @@ func (ms *maintenanceServer) Status(ctx context.Context, ar *pb.StatusRequest) (
|
|||||||
DbSize: ms.bg.Backend().Size(),
|
DbSize: ms.bg.Backend().Size(),
|
||||||
Leader: uint64(ms.rg.Leader()),
|
Leader: uint64(ms.rg.Leader()),
|
||||||
RaftIndex: ms.rg.CommittedIndex(),
|
RaftIndex: ms.rg.CommittedIndex(),
|
||||||
RaftTerm: ms.rg.Term(),
|
|
||||||
RaftAppliedIndex: ms.rg.AppliedIndex(),
|
RaftAppliedIndex: ms.rg.AppliedIndex(),
|
||||||
|
RaftTerm: ms.rg.Term(),
|
||||||
DbSizeInUse: ms.bg.Backend().SizeInUse(),
|
DbSizeInUse: ms.bg.Backend().SizeInUse(),
|
||||||
}
|
}
|
||||||
if uint64(ms.rg.Leader()) == raft.None {
|
if uint64(ms.rg.Leader()) == raft.None {
|
||||||
|
@ -1392,6 +1392,8 @@ func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (appl
|
|||||||
switch e.Type {
|
switch e.Type {
|
||||||
case raftpb.EntryNormal:
|
case raftpb.EntryNormal:
|
||||||
s.applyEntryNormal(&e)
|
s.applyEntryNormal(&e)
|
||||||
|
s.setAppliedIndex(e.Index)
|
||||||
|
s.setTerm(e.Term)
|
||||||
case raftpb.EntryConfChange:
|
case raftpb.EntryConfChange:
|
||||||
// set the consistent index of current executing entry
|
// set the consistent index of current executing entry
|
||||||
if e.Index > s.consistIndex.ConsistentIndex() {
|
if e.Index > s.consistIndex.ConsistentIndex() {
|
||||||
@ -1401,15 +1403,13 @@ func (s *EtcdServer) apply(es []raftpb.Entry, confState *raftpb.ConfState) (appl
|
|||||||
pbutil.MustUnmarshal(&cc, e.Data)
|
pbutil.MustUnmarshal(&cc, e.Data)
|
||||||
removedSelf, err := s.applyConfChange(cc, confState)
|
removedSelf, err := s.applyConfChange(cc, confState)
|
||||||
s.setAppliedIndex(e.Index)
|
s.setAppliedIndex(e.Index)
|
||||||
|
s.setTerm(e.Term)
|
||||||
shouldStop = shouldStop || removedSelf
|
shouldStop = shouldStop || removedSelf
|
||||||
s.w.Trigger(cc.ID, &confChangeResponse{s.cluster.Members(), err})
|
s.w.Trigger(cc.ID, &confChangeResponse{s.cluster.Members(), err})
|
||||||
default:
|
default:
|
||||||
plog.Panicf("entry type should be either EntryNormal or EntryConfChange")
|
plog.Panicf("entry type should be either EntryNormal or EntryConfChange")
|
||||||
}
|
}
|
||||||
atomic.StoreUint64(&s.appliedIndex, e.Index)
|
appliedi, appliedt = e.Index, e.Term
|
||||||
atomic.StoreUint64(&s.term, e.Term)
|
|
||||||
appliedt = e.Term
|
|
||||||
appliedi = e.Index
|
|
||||||
}
|
}
|
||||||
return appliedt, appliedi, shouldStop
|
return appliedt, appliedi, shouldStop
|
||||||
}
|
}
|
||||||
@ -1422,7 +1422,6 @@ func (s *EtcdServer) applyEntryNormal(e *raftpb.Entry) {
|
|||||||
s.consistIndex.setConsistentIndex(e.Index)
|
s.consistIndex.setConsistentIndex(e.Index)
|
||||||
shouldApplyV3 = true
|
shouldApplyV3 = true
|
||||||
}
|
}
|
||||||
defer s.setAppliedIndex(e.Index)
|
|
||||||
|
|
||||||
// raft state machine may generate noop entry when leader confirmation.
|
// raft state machine may generate noop entry when leader confirmation.
|
||||||
// skip it in advance to avoid some potential bug in the future
|
// skip it in advance to avoid some potential bug in the future
|
||||||
|
Loading…
x
Reference in New Issue
Block a user