pg-promise not reconnecting clients in pool after broken connection

874 Views Asked by At

I'm using pg-promise (and the underlying pg-pool lib).

When I pull the plug on my pg database briefly (break TCP connections), I get connect ETIMEDOUT errors (expected) however it is taking a very long time for the pool to re-establish a connection. Like in the order of 10 minutes.

Here is a snippet for how I am using pg-promise:

  const pgp = pgPromise({
    error(err, e) {
      if (e.query) {
        // Do stuff
      }
    },
  });

...

  const pgpArgs = {
    host,
    port,
    database,
    user,
    password,
    max,
    idleTimeoutMillis: 5000,
  };

  const db = pgp(pgpArgs);

I saw this potential answer from the author, but I don't want to kill my entire process just to re-establish the pool.

Is there a way to force clients in pool to re-connect, other than restarting the nodejs process?

Thanks in advance.

0

There are 0 best solutions below