VictoriaMetrics/VictoriaMetrics · error

cannot read minTimestamp: %w

Error message

cannot read minTimestamp: %w

What it means

readTimeRange failed to read the 8-byte minTimestamp (uint64) from the vmselect request stream. This is a wire-protocol read failure — the request was truncated or the stream errored — and the specific read error is wrapped in this message.

Source

Thrown at lib/vmselectapi/server.go:299

	bc      *handshake.BufferedConn
	sizeBuf []byte
	dataBuf []byte

	qt *querytracer.Tracer
	sq storage.SearchQuery

	// timeout in seconds for the current request
	timeout uint64

	// deadline in unix timestamp seconds for the current request.
	deadline uint64
}

func (ctx *vmselectRequestCtx) readTimeRange() (storage.TimeRange, error) {
	var tr storage.TimeRange
	minTimestamp, err := ctx.readUint64()
	if err != nil {
		return tr, fmt.Errorf("cannot read minTimestamp: %w", err)
	}
	maxTimestamp, err := ctx.readUint64()
	if err != nil {
		return tr, fmt.Errorf("cannot read maxTimestamp: %w", err)
	}
	tr.MinTimestamp = int64(minTimestamp)
	tr.MaxTimestamp = int64(maxTimestamp)
	return tr, nil
}

func (ctx *vmselectRequestCtx) readLimit() (int, error) {
	n, err := ctx.readUint32()
	if err != nil {
		return 0, fmt.Errorf("cannot read limit: %w", err)
	}
	if n > 1<<31-1 {
		n = 1<<31 - 1
	}

View on GitHub (pinned to 5079fb58f1)

Solutions

  1. Verify the client sends the full request: tenant, time range (two uint64s), and remaining fields per protocol version
  2. Check for version mismatch between client and vmselect wire formats
  3. Inspect the wrapped error: io.EOF means the client closed early; fix the client-side writer
  4. Capture a packet trace (tcpdump) to confirm truncation point
Defensive patterns

Strategy: validation

Validate before calling

// client-side: ensure the full request is written before reading the response
var buf bytes.Buffer
buf.Write(tenantBytes)
binary.Write(&buf, binary.BigEndian, uint64(minTS))
binary.Write(&buf, binary.BigEndian, uint64(maxTS))
if n, err := conn.Write(buf.Bytes()); err != nil || n != buf.Len() {
    return fmt.Errorf("incomplete vmselect request write: %w", err)
}

Try / catch

tr, err := ctx.readTimeRange()
if err != nil {
    return fmt.Errorf("bad request stream: %w", err) // check wrapped EOF vs transport
}

Prevention

When it happens

Trigger: A client sending a truncated vmselect request (fewer bytes than the protocol needs) so ctx.readUint64 hits EOF/short-read while decoding the time range in processTagValueSuffixes or processTenants.

Common situations: Buggy or mismatched client implementations of the vmselect protocol; connection closed early; proxies truncating request bodies.

Related errors


AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03). Data as JSON: /api/errors/bf90c33ea2705ecb. Report an issue: GitHub.