Skip to content

Commit

Permalink
consul: Adding a Raft command enqueue limit
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed May 10, 2014
1 parent 118b7c8 commit 686fac0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion consul/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 686fac0

Please sign in to comment.