From c2af0de522b9d89ed681035262be9d6ca0452381 Mon Sep 17 00:00:00 2001 From: songjiayang Date: Sun, 12 Jun 2022 08:06:14 +0800 Subject: [PATCH] make sure response error when TOC parse failed Signed-off-by: songjiayang --- tsdb/index/index.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tsdb/index/index.go b/tsdb/index/index.go index 29295c45f..c81441a6b 100644 --- a/tsdb/index/index.go +++ b/tsdb/index/index.go @@ -174,18 +174,15 @@ func NewTOCFromByteSlice(bs ByteSlice) (*TOC, error) { return nil, errors.Wrap(encoding.ErrInvalidChecksum, "read TOC") } - if err := d.Err(); err != nil { - return nil, err - } - - return &TOC{ + toc := &TOC{ Symbols: d.Be64(), Series: d.Be64(), LabelIndices: d.Be64(), LabelIndicesTable: d.Be64(), Postings: d.Be64(), PostingsTable: d.Be64(), - }, nil + } + return toc, d.Err() } // NewWriter returns a new Writer to the given filename. It serializes data in format version 2.