diff --git a/tsdb/chunks/head_chunks.go b/tsdb/chunks/head_chunks.go index a7edbe982c..5e3fc61017 100644 --- a/tsdb/chunks/head_chunks.go +++ b/tsdb/chunks/head_chunks.go @@ -190,23 +190,23 @@ func (cdm *ChunkDiskMapper) openMMapFiles() (returnErr error) { lastSeq := chkFileIndices[0] for _, seq := range chkFileIndices[1:] { if seq != lastSeq+1 { - return errors.Errorf("found unsequential head chunk files %d and %d", lastSeq, seq) + return errors.Errorf("found unsequential head chunk files %s (index: %d) and %s (index: %d)", files[lastSeq], lastSeq, files[seq], seq) } lastSeq = seq } for i, b := range cdm.mmappedChunkFiles { if b.byteSlice.Len() < HeadChunkFileHeaderSize { - return errors.Wrapf(errInvalidSize, "invalid head chunk file header in file %d", i) + return errors.Wrapf(errInvalidSize, "%s: invalid head chunk file header", files[i]) } // Verify magic number. if m := binary.BigEndian.Uint32(b.byteSlice.Range(0, MagicChunksSize)); m != MagicHeadChunks { - return errors.Errorf("invalid magic number %x", m) + return errors.Errorf("%s: invalid magic number %x", files[i], m) } // Verify chunk format version. if v := int(b.byteSlice.Range(MagicChunksSize, MagicChunksSize+ChunksFormatVersionSize)[0]); v != chunksFormatV1 { - return errors.Errorf("invalid chunk format version %d", v) + return errors.Errorf("%s: invalid chunk format version %d", files[i], v) } cdm.size += int64(b.byteSlice.Len()) diff --git a/tsdb/db.go b/tsdb/db.go index 1997dca2d6..a2892b6d9e 100644 --- a/tsdb/db.go +++ b/tsdb/db.go @@ -441,10 +441,14 @@ func (db *DBReadOnly) Blocks() ([]BlockReader, error) { if len(corrupted) > 0 { for _, b := range loadable { if err := b.Close(); err != nil { - level.Warn(db.logger).Log("msg", "Closing a block", err) + level.Warn(db.logger).Log("msg", "Closing block failed", "err", err, "block", b) } } - return nil, errors.Errorf("unexpected corrupted block:%v", corrupted) + var merr tsdb_errors.MultiError + for ulid, err := range corrupted { + merr.Add(errors.Wrapf(err, "corrupted block %s", ulid.String())) + } + return nil, merr.Err() } if len(loadable) == 0 { @@ -880,7 +884,11 @@ func (db *DB) reload() (err error) { block.Close() } } - return fmt.Errorf("unexpected corrupted block:%v", corrupted) + var merr tsdb_errors.MultiError + for ulid, err := range corrupted { + merr.Add(errors.Wrapf(err, "corrupted block %s", ulid.String())) + } + return merr.Err() } // All deletable blocks should not be loaded. @@ -1054,7 +1062,7 @@ func (db *DB) deleteBlocks(blocks map[ulid.ULID]*Block) error { for ulid, block := range blocks { if block != nil { if err := block.Close(); err != nil { - level.Warn(db.logger).Log("msg", "Closing block failed", "err", err) + level.Warn(db.logger).Log("msg", "Closing block failed", "err", err, "block", ulid) } } if err := os.RemoveAll(filepath.Join(db.dir, ulid.String())); err != nil {