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 {
|
if dataSize == 0 {
|
||||||
return buf, nil
|
return buf, nil
|
||||||
}
|
}
|
||||||
if _, err := io.ReadFull(bc, buf); err != nil {
|
if n, err := io.ReadFull(bc, buf); err != nil {
|
||||||
return buf, fmt.Errorf("cannot read data with size %d: %s", dataSize, err)
|
return buf, fmt.Errorf("cannot read data with size %d: %s; read only %d bytes", dataSize, err, n)
|
||||||
}
|
}
|
||||||
return buf, nil
|
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)
|
return fmt.Errorf("too big packet size: %d; shouldn't exceed %d", packetSize, consts.MaxInsertPacketSize)
|
||||||
}
|
}
|
||||||
buf = bytesutil.Resize(buf, int(packetSize))
|
buf = bytesutil.Resize(buf, int(packetSize))
|
||||||
if _, err := io.ReadFull(r, buf); err != nil {
|
if n, err := io.ReadFull(r, buf); err != nil {
|
||||||
return fmt.Errorf("cannot read packet with size %d: %s", packetSize, err)
|
return fmt.Errorf("cannot read packet with size %d: %s; read only %d bytes", packetSize, err, n)
|
||||||
}
|
}
|
||||||
vminsertPacketsRead.Inc()
|
vminsertPacketsRead.Inc()
|
||||||
|
|
||||||
|
@ -386,8 +386,8 @@ func (ctx *vmselectRequestCtx) readDataBufBytes(maxDataSize int) error {
|
||||||
if dataSize == 0 {
|
if dataSize == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if _, err := io.ReadFull(ctx.bc, ctx.dataBuf); err != nil {
|
if n, err := io.ReadFull(ctx.bc, ctx.dataBuf); err != nil {
|
||||||
return fmt.Errorf("cannot read data with size %d: %s", dataSize, err)
|
return fmt.Errorf("cannot read data with size %d: %s; read only %d bytes", dataSize, err, n)
|
||||||
}
|
}
|
||||||
return nil
|
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)
|
return nil, fmt.Errorf("cannot set read deadline: %s", err)
|
||||||
}
|
}
|
||||||
data := make([]byte, dataLen)
|
data := make([]byte, dataLen)
|
||||||
if _, err := io.ReadFull(c, data); err != nil {
|
if n, err := io.ReadFull(c, data); err != nil {
|
||||||
return nil, fmt.Errorf("cannot read message with size %d: %s", dataLen, err)
|
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 {
|
if err := c.SetReadDeadline(zeroTime); err != nil {
|
||||||
return nil, fmt.Errorf("cannot reset read deadline: %s", err)
|
return nil, fmt.Errorf("cannot reset read deadline: %s", err)
|
||||||
|
|
Loading…
Reference in a new issue