Open rmzg opened 7 years ago
Have you ever found a solution to this?
No, I haven't tried it since then.
Happening too, under heavy load.
Used this in pg-promise
- was able to resolve this bug by removing pgNative
:
const pgp = pgLib({ pgNative: true });
->const pgp = pgLib({});
2021-08-28T14:41:24: AssertionError [ERR_ASSERTION]: Must be connected to start reader
at PQ.startReader (/nix/store/nkn6lgb3s5w34zv93y0a8hs1k3gmpqgz-myapp/libexec/source/node_modules/libpq/index.js:258:3)
at module.exports.Client._startReading (/nix/store/nkn6lgb3s5w34zv93y0a8hs1k3gmpqgz-myapp/libexec/source/node_modules/pg-native/index.js:245:11)
at module.exports.<anonymous> (/nix/store/nkn6lgb3s5w34zv93y0a8hs1k3gmpqgz-myapp/libexec/source/node_modules/pg-native/index.js:36:10)
at module.exports.emit (events.js:315:20)
at module.exports.EventEmitter.emit (domain.js:467:12)
at _addListener (events.js:358:14)
at module.exports.addListener (events.js:406:10)
at /nix/store/nkn6lgb3s5w34zv93y0a8hs1k3gmpqgz-myapp/libexec/source/node_modules/pg/lib/native/client.js:103:19
App [server:1] exited with code [1] via signal [SIGINT]
the last line is from pm2
, as this raises an uncaught exception that causes pm2
to crash and restart.
This happens only under heavy (hundreds of requests per second) load so it might be difficult to debug.
I've managed to reproduce this with pg.Pool
The issue occured when I set the connectionTimeoutMillis
to a too low number like 1000 and I initiated connection to the database in a for loop...
When I increaed it to 60_000, the issue did not come up or if you set to 0 (default), then there is no timeout.
I suggest leaving the pg.Pool connectionTimeoutMillis
on 0 (default value) or set a fairly high number like 60_000 (1 minute).
I've managed to reproduce this with pg.Pool The issue occured when I set the
connectionTimeoutMillis
to a too low number like 1000 and I initiated connection to the database in a for loop... When I increaed it to 60_000, the issue did not come up or if you set to 0 (default), then there is no timeout.I suggest leaving the pg.Pool
connectionTimeoutMillis
on 0 (default value) or set a fairly high number like 60_000 (1 minute).
Thanks for the info! My connectionTimeoutMillis
setting is currently 5000ms
so this might be it. However, my host is remote and I'm worried about connections hanging indefinitely during intermittent network issues / lags.
We hit this as well. I can confirm that uninstalling pg-native
or setting connectionTimeoutMillis
from 5000
to 60000
(didn't try other values yet) both solved this for us (so far... 🙂 ).
version : 3.0.0
That throws the error:
but if you delete the
.native
part of the require line, you no longer get an error.