fix: ограничить пул Postgres и реже писать прогресс скана
- DB_MAX_OPEN_CONNS (25), DB_MAX_IDLE_CONNS (10), DB_CONN_MAX_LIFETIME_SEC (1800) - Throttle UpdateScan прогресса в Runner (500ms), меньше одновременных запросов к БД Устраняет FATAL too many clients при больших сканах и частом опросе GetScan Made-with: Cursor
This commit is contained in:
@@ -57,6 +57,15 @@ func makeStore(cfg config.Config) (scans.Store, func()) {
|
||||
log.Fatalf("db ping failed: %v", err)
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(cfg.DBMaxOpenConns)
|
||||
db.SetMaxIdleConns(cfg.DBMaxIdleConns)
|
||||
if cfg.DBConnMaxLifetime > 0 {
|
||||
db.SetConnMaxLifetime(cfg.DBConnMaxLifetime)
|
||||
log.Printf("postgres pool: max_open=%d max_idle=%d conn_max_lifetime=%v", cfg.DBMaxOpenConns, cfg.DBMaxIdleConns, cfg.DBConnMaxLifetime)
|
||||
} else {
|
||||
log.Printf("postgres pool: max_open=%d max_idle=%d conn_max_lifetime=off", cfg.DBMaxOpenConns, cfg.DBMaxIdleConns)
|
||||
}
|
||||
|
||||
if cfg.RunMigrations {
|
||||
if err = store.RunMigrations(db); err != nil {
|
||||
_ = db.Close()
|
||||
|
||||
Reference in New Issue
Block a user