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
This commit is contained in:
Aliaksandr Valialkin 2023-10-31 18:34:44 +01:00
parent 09c5ac238a
commit 2288f81c5b
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -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 {