From b319b144311e8320e8c38fe06eb6992605c75287 Mon Sep 17 00:00:00 2001 From: Mateusz Gozdek Date: Tue, 9 Nov 2021 09:17:00 +0100 Subject: [PATCH] tsdb/chunks: preallocate at least some space on non-Windows systems (#9581) To avoid potential chunk corruption read, which I am not sure why is happening. Closes #9561. Signed-off-by: Mateusz Gozdek --- tsdb/chunks/head_chunks_other.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tsdb/chunks/head_chunks_other.go b/tsdb/chunks/head_chunks_other.go index cd0e258a1a..3d00fddc37 100644 --- a/tsdb/chunks/head_chunks_other.go +++ b/tsdb/chunks/head_chunks_other.go @@ -17,5 +17,6 @@ package chunks // HeadChunkFilePreallocationSize is the size to which the m-map file should be preallocated when a new file is cut. -// Windows needs pre-allocations while the other OS does not. -var HeadChunkFilePreallocationSize int64 +// Windows needs pre-allocations while the other OS does not. But we observed that a 0 pre-allocation causes unit tests to flake. +// This small allocation for non-Windows OSes removes the flake. +var HeadChunkFilePreallocationSize int64 = MinWriteBufferSize * 2