From d006b41eff60da036af2623c123ccd587f31d323 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 14 Dec 2020 19:25:23 +0200 Subject: [PATCH] lib/persistentqueue: verify that ReaderOffset doesnt exceed WriterOffset when opening the persistent queue Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/964 --- lib/persistentqueue/persistentqueue.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/persistentqueue/persistentqueue.go b/lib/persistentqueue/persistentqueue.go index 87e4b1a55..916276c3f 100644 --- a/lib/persistentqueue/persistentqueue.go +++ b/lib/persistentqueue/persistentqueue.go @@ -336,6 +336,10 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB cleanOnError() return nil, fmt.Errorf("couldn't find chunk file for writing in %q", q.dir) } + if q.readerOffset > q.writerOffset { + cleanOnError() + return nil, fmt.Errorf("readerOffset=%d cannot exceed writerOffset=%d", q.readerOffset, q.writerOffset) + } mustCloseFlockF = false return &q, nil }