diff options
| author | bndw <ben@bdw.to> | 2026-02-14 09:44:55 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 09:44:55 -0800 |
| commit | fe3708eaf495613cc6e2340b821795f25811d6ed (patch) | |
| tree | 061f4b1c2938919ab38e0bc840c34d7c35bad42f /internal/config/config_test.go | |
| parent | 688548d4ac3293449a88913275f886fd2e103cdf (diff) | |
fix: optimize SQLite connection pooling for single-writer architecture
Remove misleading max_connections config option and properly configure
SQLite connection pooling in the storage layer.
Changes:
- Set MaxOpenConns(1) for optimal SQLite performance
- Set MaxIdleConns(1) to keep connection alive
- Set ConnMaxLifetime(0) to never close connection
- Remove max_connections and max_lifetime from DatabaseConfig
- Update docs to clarify SQLite's single-writer architecture
Rationale:
SQLite is an embedded database with a single-writer lock. Multiple
connections cause lock contention and reduce performance. WAL mode
allows concurrent reads from the same connection, making connection
pooling unnecessary and counterproductive.
This change makes the configuration clearer and ensures optimal
SQLite performance by using a single long-lived connection.
Diffstat (limited to 'internal/config/config_test.go')
| -rw-r--r-- | internal/config/config_test.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 50d9b67..e1df1aa 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go | |||
| @@ -257,7 +257,6 @@ server: | |||
| 257 | 257 | ||
| 258 | database: | 258 | database: |
| 259 | path: "test.db" | 259 | path: "test.db" |
| 260 | max_lifetime: "30m" | ||
| 261 | 260 | ||
| 262 | rate_limit: | 261 | rate_limit: |
| 263 | cleanup_interval: "10m" | 262 | cleanup_interval: "10m" |
| @@ -282,7 +281,7 @@ rate_limit: | |||
| 282 | t.Errorf("expected write timeout 2m, got %v", cfg.Server.WriteTimeout) | 281 | t.Errorf("expected write timeout 2m, got %v", cfg.Server.WriteTimeout) |
| 283 | } | 282 | } |
| 284 | 283 | ||
| 285 | if cfg.Database.MaxLifetime != 30*time.Minute { | 284 | if cfg.RateLimit.CleanupInterval != 10*time.Minute { |
| 286 | t.Errorf("expected max lifetime 30m, got %v", cfg.Database.MaxLifetime) | 285 | t.Errorf("expected cleanup interval 10m, got %v", cfg.RateLimit.CleanupInterval) |
| 287 | } | 286 | } |
| 288 | } | 287 | } |
