From a9acd29effe5e7de622d8c21b98596ce028cd454 Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 27 Jan 2026 13:59:01 +0100 Subject: [PATCH] feat: enable SQLite WAL by default (#11059) - In order to avoid a database locked message, you either need shared cache or WAL. Shared cache was disabled in as its deprecrated and could cause more good than trouble. Enable WAL by default, it's only non-desirable in very narrow and select situations (NFS filesystem situation) and is otherwise safe as default. - Resolves forgejo/forgejo#10900 Docs: forgejo/docs!1717 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11059 Reviewed-by: Mathieu Fenniak Reviewed-by: Michael Kriese Co-authored-by: Gusted Co-committed-by: Gusted --- custom/conf/app.example.ini | 2 +- modules/setting/database.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6a30600a5d..568091b058 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -362,7 +362,7 @@ RUN_USER = ; git DB_TYPE = sqlite3 ;PATH= ; defaults to data/forgejo.db ;SQLITE_TIMEOUT = ; Query timeout defaults to: 500 -;SQLITE_JOURNAL_MODE = ; defaults to sqlite database default (often DELETE), can be used to enable WAL mode. https://www.sqlite.org/pragma.html#pragma_journal_mode +;SQLITE_JOURNAL_MODE = WAL; defaults to sqlite database default (often DELETE), can be used to enable WAL mode. https://www.sqlite.org/pragma.html#pragma_journal_mode ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/modules/setting/database.go b/modules/setting/database.go index 4edd0897d8..7b9af1598e 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -87,7 +87,7 @@ func loadDBSetting(rootCfg ConfigProvider) { Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "forgejo.db")) Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) - Database.SQLiteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString("") + Database.SQLiteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString("WAL") Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(2) if Database.Type.IsMySQL() {