Skip to content

pg-ears is leaking Postgres connections after network reconnect #6

Description

@cschwaderer

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions