consul: Adding a warning for large raft entries
This commit is contained in:
parent
c1ae3d78ef
commit
de507c0317
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue