From 7fe4ee2f3ba316ccef8c20234be7ead09dbf9a7f Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Mon, 4 Mar 2024 16:23:50 +0100 Subject: [PATCH] loopdb: make sqlite sync for extra durability --- loopdb/sqlite.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/loopdb/sqlite.go b/loopdb/sqlite.go index ac86877..068fb9a 100644 --- a/loopdb/sqlite.go +++ b/loopdb/sqlite.go @@ -68,6 +68,21 @@ func NewSqliteStore(cfg *SqliteConfig, network *chaincfg.Params) (*SqliteSwapSto name: "busy_timeout", value: "5000", }, + { + // With the WAL mode, this ensures that we also do an + // extra WAL sync after each transaction. The normal + // sync mode skips this and gives better performance, + // but risks durability. + name: "synchronous", + value: "full", + }, + { + // This is used to ensure proper durability for users + // running on Mac OS. It uses the correct fsync system + // call to ensure items are fully flushed to disk. + name: "fullfsync", + value: "true", + }, } sqliteOptions := make(url.Values) for _, option := range pragmaOptions {