From a5ab73e67d94d6d1a8b548bebe0c611b68d715b6 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 28 Apr 2014 22:25:09 -0700 Subject: [PATCH] consul: Adding a warning for large raft entries --- consul/rpc.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/consul/rpc.go b/consul/rpc.go index fa80a582d8..383fbf7df5 100644 --- a/consul/rpc.go +++ b/consul/rpc.go @@ -25,6 +25,10 @@ const ( const ( 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 @@ -193,6 +197,11 @@ func (s *Server) raftApply(t structs.MessageType, msg interface{}) (interface{}, 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) if err := future.Error(); err != nil { return nil, err