consul: Adding a warning for large raft entries

This commit is contained in:
Armon Dadgar 2014-04-28 22:25:09 -07:00
parent 2dd0d80274
commit a5ab73e67d
1 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,10 @@ const (
const ( const (
maxQueryTime = 600 * time.Second maxQueryTime = 600 * time.Second
// Warn if the Raft command is larger than this.
// If it's over 8MB something is probably being abusive.
raftWarnSize = 8 * 1024 * 1024
) )
// listen is used to listen for incoming RPC connections // listen is used to listen for incoming RPC connections
@ -193,6 +197,11 @@ func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{},
return nil, fmt.Errorf("Failed to encode request: %v", err) return nil, fmt.Errorf("Failed to encode request: %v", err)
} }
// Warn if the command is very large
if n := len(buf); n > raftWarnSize {
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, 0)
if err := future.Error(); err != nil { if err := future.Error(); err != nil {
return nil, err return nil, err