mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
init peerStats in transportation.go; avoid nil pointer due to restart from snapshot(we do not keep stats in persistentlayer yet)
This commit is contained in:
parent
24b34d0a1e
commit
a8ff1b27d4
@ -170,10 +170,6 @@ func (c *JoinCommand) Apply(raftServer *raft.Server) (interface{}, error) {
|
||||
value := fmt.Sprintf("raft=%s&etcd=%s&raftVersion=%s", c.RaftURL, c.EtcdURL, c.RaftVersion)
|
||||
etcdStore.Set(key, value, time.Unix(0, 0), raftServer.CommitIndex())
|
||||
|
||||
if c.Name != r.Name() {
|
||||
r.peersStats[c.Name] = &raftPeerStats{MinLatency: 1 << 63}
|
||||
}
|
||||
|
||||
return b, err
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,11 @@ func (t *transporter) SendAppendEntriesRequest(server *raft.Server, peer *raft.P
|
||||
|
||||
thisPeerStats, ok := r.peersStats[peer.Name]
|
||||
|
||||
if !ok { // we first see this peer
|
||||
thisPeerStats = &raftPeerStats{MinLatency: 1 << 63}
|
||||
r.peersStats[peer.Name] = thisPeerStats
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
resp, err := t.Post(fmt.Sprintf("%s/log/append", u), &b)
|
||||
@ -85,8 +90,6 @@ func (t *transporter) SendAppendEntriesRequest(server *raft.Server, peer *raft.P
|
||||
}
|
||||
}
|
||||
|
||||
r.peersStats[peer.Name] = thisPeerStats
|
||||
|
||||
if resp != nil {
|
||||
defer resp.Body.Close()
|
||||
aersp = &raft.AppendEntriesResponse{}
|
||||
@ -211,7 +214,7 @@ func (t *transporter) Get(path string) (*http.Response, error) {
|
||||
|
||||
func (t *transporter) waitResponse(responseChan chan *transporterResponse) (*http.Response, error) {
|
||||
|
||||
timeoutChan := time.After(t.timeout)
|
||||
timeoutChan := time.After(t.timeout * 10)
|
||||
|
||||
select {
|
||||
case <-timeoutChan:
|
||||
|
Loading…
x
Reference in New Issue
Block a user