FKITDEV-7973: Sequelize Connection Pool Right-Sizing

Problem

Default Sequelize pool (max: 100) per process, across 7 Supervisor-managed processes, exhausted PostgreSQL connection slots in dev environments. Error: SequelizeConnectionError: remaining connection slots are reserved for roles with the SUPERUSER attribute, triggered in the “Audit log forward” cron job.

Root Cause

server/db/sequelize.js only set pool.max: 100 with no lifecycle settings (idle, acquire, evict). With 7 processes each potentially opening 100 connections (700 total), and PostgreSQL defaults of 100-200 max_connections, slots got exhausted. Stale connections never released.

Fix Applied

Changed server/db/sequelize.js pool defaults:

  • max: 100max: 10 (7×10=70, safe for PG defaults)
  • Added min: 2 (baseline warm connections)
  • Added idle: 10000 (release idle connections after 10s)
  • Added acquire: 30000 (30s timeout acquiring from pool)
  • Added evict: 10000 (check for idle connections every 10s)

Also fixed shallow Object.assign to deep-merge pool config, so individual pool properties can be overridden via db.options.pool.* in config files without losing other defaults.

Escalation Path

If pool tuning doesn’t resolve, check for multiple Sequelize instances and consider PgBouncer for connection multiplexing.