node-postgres
node-postgres copied to clipboard
Pool min size
Hi. It seems that min parameter of Pool configuration is not used.
Code
let pool = new Pool({
database: connectionConfig.database,
port: connectionConfig.port,
nolimit: connectionConfig.nolimit,
user: connectionConfig.user,
password: connectionConfig.password,
host: connectionConfig.host,
min: 1
});
Expected: At least one connection is always established
Actual:
I receive a removed event with pool.totalCount equals to zero. After that my process is terminated.
min doesn’t exist. I don’t think nolimit does either.
Strange, I think it can be useful: e.g. I want to know that there is a problem with a connection to DB before my app come in a state when it needs to perform a query.
Right now when I detect that pool.totalCount is zero, I send SELECT now() to DB to maintain the connection.
I also have a requirement to maintain a given, minimum number of connections to the database. Is there a known workaround to achieve this? I noticed that PgBouncer supports this but i prefer to use node-postgres if a viable workaround is available.
@brianc This would be a nice feature. Any reason it isn't supported given that we can just leverage generic-pool functionality for this?
Would be nice to have this for compatibility with postgres.
https://github.com/gajus/postgres-bridge/commit/2463f7fcb4fad147eadbfbbdf6683b838c53c9e2
Upon a second look, it looks like Pool is not using generic-pool, contrary to what I thought.
Hi @brianc Is there any future roadmap to support this feature??