From 98699f203b5773d263ba1de15b86adf033a093d3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 31 Oct 2023 18:34:44 +0100 Subject: [PATCH] lib/persistentqueue: properly re-create flock.lock file inside directory if persistent queue is broken. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5249 Thanks to @Sniper91 for the bugreport and initial fix at https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5233 --- lib/persistentqueue/persistentqueue.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/persistentqueue/persistentqueue.go b/lib/persistentqueue/persistentqueue.go index 1bc582d36..e45cc0633 100644 --- a/lib/persistentqueue/persistentqueue.go +++ b/lib/persistentqueue/persistentqueue.go @@ -188,7 +188,9 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB } // path contents is broken or missing. Re-create it from scratch. + fs.MustClose(q.flockF) fs.RemoveDirContents(path) + q.flockF = fs.MustCreateFlockFile(path) mi.Reset() mi.Name = q.name if err := mi.WriteToFile(metainfoPath); err != nil {