From 2eef3e76b8f5f6aed9361ca6a25c752a5bf4e174 Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Tue, 19 Apr 2022 20:15:37 +0000 Subject: [PATCH] check return status of cutnewfile Signed-off-by: Mauro Stettler --- tsdb/chunks/head_chunks.go | 2 -- tsdb/chunks/head_chunks_test.go | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tsdb/chunks/head_chunks.go b/tsdb/chunks/head_chunks.go index 52912f486a..1bb7e14cbe 100644 --- a/tsdb/chunks/head_chunks.go +++ b/tsdb/chunks/head_chunks.go @@ -489,7 +489,6 @@ func (cdm *ChunkDiskMapper) CutNewFile() error { defer cdm.evtlPosMtx.Unlock() cdm.evtlPos.cutFileOnNextChunk() - return nil } @@ -801,7 +800,6 @@ func (cdm *ChunkDiskMapper) IterateAllChunks(f func(seriesRef HeadSeriesRef, chu if seriesRef == 0 && mint == 0 && maxt == 0 { break } - // Encoding. chkEnc := chunkenc.Encoding(mmapFile.byteSlice.Range(idx, idx+ChunkEncodingSize)[0]) idx += ChunkEncodingSize diff --git a/tsdb/chunks/head_chunks_test.go b/tsdb/chunks/head_chunks_test.go index 5820c1242e..2e650ab14e 100644 --- a/tsdb/chunks/head_chunks_test.go +++ b/tsdb/chunks/head_chunks_test.go @@ -116,7 +116,7 @@ func TestChunkDiskMapper_WriteChunk_Chunk_IterateChunks(t *testing.T) { } } addChunks(100) - hrw.CutNewFile() + require.NoError(t, hrw.CutNewFile()) addChunks(10) // For chunks in in-memory buffer. } @@ -254,7 +254,7 @@ func TestChunkDiskMapper_Truncate(t *testing.T) { // Create segments 1 to 7. for i := 1; i <= 7; i++ { - hrw.CutNewFile() + require.NoError(t, hrw.CutNewFile()) mint := int64(addChunk()) if i == 3 { thirdFileMinT = mint @@ -453,7 +453,7 @@ func TestHeadReadWriter_ReadRepairOnEmptyLastFile(t *testing.T) { nonEmptyFile := func() { t.Helper() - hrw.CutNewFile() + require.NoError(t, hrw.CutNewFile()) addChunk() }