From 85b95ee14300324f4950cdca13df1e04e84cc330 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 14 Oct 2020 13:15:39 +0200 Subject: [PATCH] Disable writes sync in persistent cache (#21754) With default configuration, every write is synced to disk. For the persistent cache, Beats not need to guarantee that everything is on disk, as the data can be recovered from the source endpoints, but the database was not being properly closed, so there could happen that most of the recent data was lost if the beat is stopped. Now, the processors can close their resources, so the database is properly closed in an normal shutdown, so we can go on without syncs on writes, what gives a much better performance. --- x-pack/libbeat/persistentcache/store.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/libbeat/persistentcache/store.go b/x-pack/libbeat/persistentcache/store.go index 589fc724e01..e14b90fedda 100644 --- a/x-pack/libbeat/persistentcache/store.go +++ b/x-pack/libbeat/persistentcache/store.go @@ -36,10 +36,7 @@ func newStore(logger *logp.Logger, dir, name string) (*Store, error) { // Opinionated options for the use of badger as a store for metadata caches in Beats. options := badger.DefaultOptions(dbPath) options.Logger = badgerLogger{logger.Named("badger")} - // TODO: Disabling sync writes gives better performance, and data loss wouldn't - // be a problem for caches. But we are not properly closing processors yet, so let - // sync on writes by now. - // options.SyncWrites = false + options.SyncWrites = false db, err := badger.Open(options) if err != nil {