fix: limit sqlite connection pool

This commit is contained in:
2026-06-21 17:18:23 +02:00
committed by Milas Holsting
parent e87af49dff
commit b5281df6a5

View File

@@ -19,6 +19,9 @@ func Open(dbFile string) (*sql.DB, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open db: %w", err) return nil, fmt.Errorf("failed to open db: %w", err)
} }
db.SetMaxOpenConns(1)
db.SetMaxIdleConns(1)
// WAL improves concurrency between readers and writers. // WAL improves concurrency between readers and writers.
if _, err := db.ExecContext(context.Background(), "PRAGMA journal_mode=WAL;"); err != nil { if _, err := db.ExecContext(context.Background(), "PRAGMA journal_mode=WAL;"); err != nil {
return nil, fmt.Errorf("failed to enable WAL mode: %w", err) return nil, fmt.Errorf("failed to enable WAL mode: %w", err)