Browse Source

Merge pull request #7176 from heyitsanthony/bump-lread-timeout

etcdserver: use ReqTimeout for linearized read
Anthony Romano 9 years ago
parent
commit
1a962df596
1 changed files with 2 additions and 3 deletions
  1. 2 3
      etcdserver/v3_server.go

+ 2 - 3
etcdserver/v3_server.go

@@ -714,7 +714,6 @@ func (s *EtcdServer) Watchable() mvcc.WatchableKV { return s.KV() }
 
 
 func (s *EtcdServer) linearizableReadLoop() {
 func (s *EtcdServer) linearizableReadLoop() {
 	var rs raft.ReadState
 	var rs raft.ReadState
-	internalTimeout := time.Second
 
 
 	for {
 	for {
 		ctx := make([]byte, 8)
 		ctx := make([]byte, 8)
@@ -733,7 +732,7 @@ func (s *EtcdServer) linearizableReadLoop() {
 		s.readNotifier = nextnr
 		s.readNotifier = nextnr
 		s.readMu.Unlock()
 		s.readMu.Unlock()
 
 
-		cctx, cancel := context.WithTimeout(context.Background(), internalTimeout)
+		cctx, cancel := context.WithTimeout(context.Background(), s.Cfg.ReqTimeout())
 		if err := s.r.ReadIndex(cctx, ctx); err != nil {
 		if err := s.r.ReadIndex(cctx, ctx); err != nil {
 			cancel()
 			cancel()
 			if err == raft.ErrStopped {
 			if err == raft.ErrStopped {
@@ -758,7 +757,7 @@ func (s *EtcdServer) linearizableReadLoop() {
 					// continue waiting for the response of the current requests.
 					// continue waiting for the response of the current requests.
 					plog.Warningf("ignored out-of-date read index response (want %v, got %v)", rs.RequestCtx, ctx)
 					plog.Warningf("ignored out-of-date read index response (want %v, got %v)", rs.RequestCtx, ctx)
 				}
 				}
-			case <-time.After(internalTimeout):
+			case <-time.After(s.Cfg.ReqTimeout()):
 				plog.Warningf("timed out waiting for read index response")
 				plog.Warningf("timed out waiting for read index response")
 				nr.notify(ErrTimeout)
 				nr.notify(ErrTimeout)
 				timeout = true
 				timeout = true