lib/encoding: log the compressed block contents if it cannot be decompressed or unmarshaled

This should help detecting the root cause of https://github.com/VictoriaMetrics/VictoriaMetrics/issues/281
This commit is contained in:
Aliaksandr Valialkin 2019-12-24 20:47:43 +02:00
parent 5bb39e757b
commit 4ba4abe666

View File

@ -166,24 +166,24 @@ func unmarshalInt64Array(dst []int64, src []byte, mt MarshalType, firstValue int
bb := bbPool.Get() bb := bbPool.Get()
bb.B, err = DecompressZSTD(bb.B[:0], src) bb.B, err = DecompressZSTD(bb.B[:0], src)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot decompress zstd data of size %d: %s", len(src), err) return nil, fmt.Errorf("cannot decompress zstd data of size %d: %s; src_zstd=%X", len(src), err, src)
} }
dst, err = unmarshalInt64NearestDelta(dst, bb.B, firstValue, itemsCount) dst, err = unmarshalInt64NearestDelta(dst, bb.B, firstValue, itemsCount)
bbPool.Put(bb) bbPool.Put(bb)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot unmarshal nearest delta data after zstd decompression: %s", err) return nil, fmt.Errorf("cannot unmarshal nearest delta data after zstd decompression: %s; src_zstd=%X", err, src)
} }
return dst, nil return dst, nil
case MarshalTypeZSTDNearestDelta2: case MarshalTypeZSTDNearestDelta2:
bb := bbPool.Get() bb := bbPool.Get()
bb.B, err = DecompressZSTD(bb.B[:0], src) bb.B, err = DecompressZSTD(bb.B[:0], src)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot decompress zstd data of size %d: %s", len(src), err) return nil, fmt.Errorf("cannot decompress zstd data of size %d: %s; src_zstd=%X", len(src), err, src)
} }
dst, err = unmarshalInt64NearestDelta2(dst, bb.B, firstValue, itemsCount) dst, err = unmarshalInt64NearestDelta2(dst, bb.B, firstValue, itemsCount)
bbPool.Put(bb) bbPool.Put(bb)
if err != nil { if err != nil {
return nil, fmt.Errorf("cannot unmarshal nearest delta2 data after zstd decompression: %s", err) return nil, fmt.Errorf("cannot unmarshal nearest delta2 data after zstd decompression: %s; src_zstd=%X", err, src)
} }
return dst, nil return dst, nil
case MarshalTypeNearestDelta: case MarshalTypeNearestDelta: