summaryrefslogtreecommitdiff
path: root/internal/db
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-10-13 22:19:52 +0000
committerLibravatar GitHub <noreply@github.com>2024-10-14 00:19:52 +0200
commit2076f7d85f508a1904ecd1f8e3f9dba2192c8b52 (patch)
tree2a19cf3e1ec4a25391119f8d4a491c8ea2fc6dc6 /internal/db
parent[chore/docs] Add `/gotosocial/.cache` to Docker container, document `GTS_WAZE... (diff)
downloadgotosocial-2076f7d85f508a1904ecd1f8e3f9dba2192c8b52.tar.xz
[feature] for an sqlite database with journal mode != WAL, use maximum of 1 open conn (#3428)
Diffstat (limited to 'internal/db')
-rw-r--r--internal/db/bundb/bundb.go12
1 files changed, 12 insertions, 0 deletions
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)
}