From 686fac0e4933d213acc380acca13737fc1973bda Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 9 May 2014 19:16:40 -0700 Subject: [PATCH] consul: Adding a Raft command enqueue limit --- consul/rpc.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/consul/rpc.go b/consul/rpc.go index b4b7ec8c49f3..23617bc39030 100644 --- a/consul/rpc.go +++ b/consul/rpc.go @@ -24,11 +24,18 @@ const ( ) const ( + // maxQueryTime is used to bound the limit of a blocking query maxQueryTime = 600 * time.Second // Warn if the Raft command is larger than this. // If it's over 1MB something is probably being abusive. raftWarnSize = 1024 * 1024 + + // enqueueLimit caps how long we will wait to enqueue + // a new Raft command. Something is probably wrong if this + // value is ever reached. However, it prevents us from blocking + // the requesting goroutine forever. + enqueueLimit = 30 * time.Second ) // listen is used to listen for incoming RPC connections @@ -202,7 +209,7 @@ func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{}, s.logger.Printf("[WARN] consul: Attempting to apply large raft entry (%d bytes)", n) } - future := s.raft.Apply(buf, 0) + future := s.raft.Apply(buf, enqueueLimit) if err := future.Error(); err != nil { return nil, err }