From 20fc0e0e543e9f46b9227f51a6a1ddfeb35302ca Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 11 Jun 2019 21:46:21 +0300 Subject: [PATCH] lib/{storage,mergeset}: sync filenames inside part when finalizing the part Fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/63 --- lib/mergeset/block_stream_writer.go | 6 ++++++ lib/storage/block_stream_writer.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/mergeset/block_stream_writer.go b/lib/mergeset/block_stream_writer.go index b6682a686..67826b494 100644 --- a/lib/mergeset/block_stream_writer.go +++ b/lib/mergeset/block_stream_writer.go @@ -151,6 +151,12 @@ func (bsw *blockStreamWriter) MustClose() { bsw.itemsWriter.MustClose() bsw.lensWriter.MustClose() + // Sync bsw.path contents to make sure it doesn't disappear + // after system crash or power loss. + if bsw.path != "" { + fs.SyncPath(bsw.path) + } + bsw.reset() } diff --git a/lib/storage/block_stream_writer.go b/lib/storage/block_stream_writer.go index 89e098d7d..3b7f56010 100644 --- a/lib/storage/block_stream_writer.go +++ b/lib/storage/block_stream_writer.go @@ -146,6 +146,12 @@ func (bsw *blockStreamWriter) MustClose() { bsw.indexWriter.MustClose() bsw.metaindexWriter.MustClose() + // Sync bsw.path contents to make sure it doesn't disappear + // after system crash or power loss. + if bsw.path != "" { + fs.SyncPath(bsw.path) + } + bsw.reset() }