From 2076f7d85f508a1904ecd1f8e3f9dba2192c8b52 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Sun, 13 Oct 2024 22:19:52 +0000 Subject: [PATCH] [feature] for an sqlite database with journal mode != WAL, use maximum of 1 open conn (#3428) --- internal/db/bundb/bundb.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index 45607ea15..b5d3ff003 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -401,6 +401,18 @@ func maxOpenConns() int { if multiplier < 1 { return 1 } + + // Specifically for SQLite databases with + // a journal mode of anything EXCEPT "wal", + // only 1 concurrent connection is supported. + if strings.ToLower(config.GetDbType()) == "sqlite" { + journalMode := config.GetDbSqliteJournalMode() + journalMode = strings.ToLower(journalMode) + if journalMode != "wal" { + return 1 + } + } + return multiplier * runtime.GOMAXPROCS(0) }