-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I'm using pg-ears 1.2.1 with Postgres 11.6 (Node.js 12.14)
I have found out that pg-ears is leaking Postgres connections in situations described below:
-
Connect a Node.js application via pg-ears to a remote Postgres instance via
pgEars.listen(... -
Run
SELECT * FROM pg_stat_activity WHERE query = 'LISTEN <<your channel name here>>;';on your Postgres instance -> it should show only one entry for your application. -
Disconnect the network connection between the machine where your Node.js app runs on and the Postgres machine (I did it by simply plugging off the network cable, but there are more sophisticated ways to achieve this)
-
Wait till pg-ears noticed the connection loss (you should see some logs if you have included logging in your code)
-
Reconnect your network
-
Wait a few seconds and then run
SELECT * FROM pg_stat_activity WHERE query = 'LISTEN <<your channel name here>>;';again -> there are now two connections for your application
If you have an unreliable network connection, you will shortly run out of Postgres connections.