sqldb+lncfg: use SQLite-appropriate default for max connections
Both the sqldb and kvdb SQLite layers were not using a sensible default for MaxConnections. The sqldb store used defaultMaxConns (25) which is meant for Postgres, and the kvdb path passed 0 (unlimited) to sqlbase.Init when unconfigured. Add a MaxConns() method on SqliteConfig that returns the configured value or defaults to 2, appropriate for SQLite's single-writer model. Use it in both sqldb/sqlite.go and lncfg/db.go so both layers share the same default.
This commit is contained in:
3 files changed
+21
-3
No files matched your search
+2
-2
@@ -136,8 +136,8 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) {
|
||||
err)
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(defaultMaxConns)
|
||||
db.SetMaxIdleConns(defaultMaxConns)
|
||||
db.SetMaxOpenConns(cfg.MaxConns())
|
||||
db.SetMaxIdleConns(cfg.MaxConns())
|
||||
db.SetConnMaxLifetime(connIdleLifetime)
|
||||
queries := sqlc.New(db)
|
||||
|
||||
|
||||
Reference in new issue
Block a user