brianc / node-postgres

PostgreSQL client for node.js.
https://node-postgres.com
MIT License
12.05k stars 1.21k forks source link

Pool min size #1869

Open krabradosty opened 5 years ago

krabradosty commented 5 years ago

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.

charmander commented 5 years ago

min doesn’t exist. I don’t think nolimit does either.

krabradosty commented 5 years ago

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.

champikasam commented 2 years ago

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.

gajus commented 1 year ago

@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

gajus commented 1 year ago

Upon a second look, it looks like Pool is not using generic-pool, contrary to what I thought.

Smriti-OSS commented 1 year ago

Hi @brianc Is there any future roadmap to support this feature??