Commit Graph

9 Commits

Author SHA1 Message Date
ayi21sui 855c269fb8 fix: SQLite connection leak causing unbounded memory growth
SaveStats returned tx.Create().Error directly without assigning to the
local err variable, so the deferred closure always saw err==nil and
called Commit() on a failed transaction. This left the underlying
go-sqlite3 connection unreturned to the pool. With StatsJob firing
every 10s, leaked connections accumulated ~150 KB each, reaching
400+ MB after ~33 hours.

Fixes:
- stats.go: assign Create result to err so defer can Rollback on failure
- backup.go: defer-close backupDb to prevent pool leak on early return
- migration/main.go: defer-close migration db
- db.go: add ConnMaxIdleTime(5m), lower MaxIdleConns to 2, set
  _cache_size=-200 to reduce per-connection memory from ~2 MB to ~200 KB

Measured: RSS dropped from 419 MB to 66 MB, db file descriptors from
4484 to 6, with zero growth over 3-minute observation window.
2026-05-07 12:30:59 +08:00
Alireza Ahmadi 9d35e02e0e fix db WAL memory leak #1056 2026-03-22 19:08:31 +01:00
Alireza Ahmadi 14ea27292f use journal mode WAL for expand db use 2026-03-08 23:18:42 +01:00
Alireza Ahmadi 90976cded1 fix dblock on failure #964 2026-02-08 21:19:28 +01:00
Alireza Ahmadi 7751c8fce0 go package 2025-09-18 23:19:56 +02:00
Alireza Ahmadi fc410c9a8d update new features service-dns 2025-05-28 23:00:19 +02:00
Alireza Ahmadi 1535338e0b fix jsonsub required rules #451 2025-02-15 14:13:54 +01:00
Alireza Ahmadi 1ac7bce6b4 new api with token 2025-02-02 21:46:36 +01:00
Alireza Ahmadi 7faa28a89d separate frontend repository 2025-01-29 00:08:36 +01:00