mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: time out when readStateC is blocking
Otherwise, it will block forever when the server is overloaded. Fix https://github.com/coreos/etcd/issues/6891.
This commit is contained in:
parent
2509e7ad2c
commit
3fd1d951f8
@ -135,6 +135,7 @@ func (r *raftNode) start(rh *raftReadyHandler) {
|
||||
r.applyc = make(chan apply)
|
||||
r.stopped = make(chan struct{})
|
||||
r.done = make(chan struct{})
|
||||
internalTimeout := time.Second
|
||||
|
||||
go func() {
|
||||
defer r.onStop()
|
||||
@ -167,6 +168,8 @@ func (r *raftNode) start(rh *raftReadyHandler) {
|
||||
if len(rd.ReadStates) != 0 {
|
||||
select {
|
||||
case r.readStateC <- rd.ReadStates[len(rd.ReadStates)-1]:
|
||||
case <-time.After(internalTimeout):
|
||||
plog.Warningf("timed out sending read state")
|
||||
case <-r.stopped:
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user