consul: Adding a Raft command enqueue limit

This commit is contained in:
Armon Dadgar 2014-05-09 19:16:40 -07:00
parent 9b9ecd6c6f
commit 813ebf0b0c
1 changed files with 8 additions and 1 deletions

View File

@ -24,11 +24,18 @@ const (
) )
const ( const (
// maxQueryTime is used to bound the limit of a blocking query
maxQueryTime = 600 * time.Second maxQueryTime = 600 * time.Second
// Warn if the Raft command is larger than this. // Warn if the Raft command is larger than this.
// If it's over 1MB something is probably being abusive. // If it's over 1MB something is probably being abusive.
raftWarnSize = 1024 * 1024 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 // 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) 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 { if err := future.Error(); err != nil {
return nil, err return nil, err
} }