mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
all: report the number of bytes read on io.ReadFull error
This should simplify error investigation similar to https://github.com/VictoriaMetrics/VictoriaMetrics/issues/175
This commit is contained in:
parent
2f4c950fe9
commit
b101064f8b
3 changed files with 8 additions and 8 deletions
|
@ -1296,8 +1296,8 @@ func readBytes(buf []byte, bc *handshake.BufferedConn, maxDataSize int) ([]byte,
|
|||
if dataSize == 0 {
|
||||
return buf, nil
|
||||
}
|
||||
if _, err := io.ReadFull(bc, buf); err != nil {
|
||||
return buf, fmt.Errorf("cannot read data with size %d: %s", dataSize, err)
|
||||
if n, err := io.ReadFull(bc, buf); err != nil {
|
||||
return buf, fmt.Errorf("cannot read data with size %d: %s; read only %d bytes", dataSize, err, n)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
|
|
@ -291,8 +291,8 @@ func (s *Server) processVMInsertConn(r io.Reader) error {
|
|||
return fmt.Errorf("too big packet size: %d; shouldn't exceed %d", packetSize, consts.MaxInsertPacketSize)
|
||||
}
|
||||
buf = bytesutil.Resize(buf, int(packetSize))
|
||||
if _, err := io.ReadFull(r, buf); err != nil {
|
||||
return fmt.Errorf("cannot read packet with size %d: %s", packetSize, err)
|
||||
if n, err := io.ReadFull(r, buf); err != nil {
|
||||
return fmt.Errorf("cannot read packet with size %d: %s; read only %d bytes", packetSize, err, n)
|
||||
}
|
||||
vminsertPacketsRead.Inc()
|
||||
|
||||
|
@ -386,8 +386,8 @@ func (ctx *vmselectRequestCtx) readDataBufBytes(maxDataSize int) error {
|
|||
if dataSize == 0 {
|
||||
return nil
|
||||
}
|
||||
if _, err := io.ReadFull(ctx.bc, ctx.dataBuf); err != nil {
|
||||
return fmt.Errorf("cannot read data with size %d: %s", dataSize, err)
|
||||
if n, err := io.ReadFull(ctx.bc, ctx.dataBuf); err != nil {
|
||||
return fmt.Errorf("cannot read data with size %d: %s; read only %d bytes", dataSize, err, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -158,8 +158,8 @@ func readData(c net.Conn, dataLen int) ([]byte, error) {
|
|||
return nil, fmt.Errorf("cannot set read deadline: %s", err)
|
||||
}
|
||||
data := make([]byte, dataLen)
|
||||
if _, err := io.ReadFull(c, data); err != nil {
|
||||
return nil, fmt.Errorf("cannot read message with size %d: %s", dataLen, err)
|
||||
if n, err := io.ReadFull(c, data); err != nil {
|
||||
return nil, fmt.Errorf("cannot read message with size %d: %s; read only %d bytes", dataLen, err, n)
|
||||
}
|
||||
if err := c.SetReadDeadline(zeroTime); err != nil {
|
||||
return nil, fmt.Errorf("cannot reset read deadline: %s", err)
|
||||
|
|
Loading…
Reference in a new issue