mauricio / postgresql-async

Async, Netty based, database drivers for PostgreSQL and MySQL written in Scala
Apache License 2.0
1.43k stars 222 forks source link

connection pool seems to be unbound #213

Closed domdorn closed 7 years ago

domdorn commented 7 years ago

When firing a lot of queries through my play 2.5 app, I get errors like these:

error] c.g.m.a.d.p.PostgreSQLConnection - Error with message -> ErrorMessage(fields=Map(Line -> 340, File -> proc.c, SQLSTATE -> 53300, Routine -> InitProcess, V -> FATAL, Message -> sorry, too many clients already, Severity -> FATAL)) [error] c.g.m.a.d.p.PostgreSQLConnection - Error with message -> ErrorMessage(fields=Map(Line -> 340, File -> proc.c, SQLSTATE -> 53300, Routine -> InitProcess, V -> FATAL, Message -> sorry, too many clients already, Severity -> FATAL)) [error] c.g.m.a.d.p.PostgreSQLConnection - Error with message -> ErrorMessage(fields=Map(Line -> 779, File -> postinit.c, SQLSTATE -> 53300, Routine -> InitPostgres, V -> FATAL, Message -> remaining connection slots are reserved for non-replication superuser connections, Severity -> FATAL)) [error] c.g.m.a.d.p.PostgreSQLConnection - Error with message -> ErrorMessage(fields=Map(Line -> 779, File -> postinit.c, SQLSTATE -> 53300, Routine -> InitPostgres, V -> FATAL, Message -> remaining connection slots are reserved for non-replication superuser connections, Severity -> FATAL)) [error] c.g.m.a.d.p.PostgreSQLConnection - Error with message -> ErrorMessage(fields=Map(Line -> 779, File -> postinit.c, SQLSTATE -> 53300, Routine -> InitPostgres, V -> FATAL, Message -> remaining connection slots are reserved for non-replication superuser connections, Severity -> FATAL)) [error] c.g.m.a.d.p.PostgreSQLConnection - Error on connection com.github.mauricio.async.db.postgresql.exceptions.GenericDatabaseException: ErrorMessage(fields=Map(Line -> 340, File -> proc.c, SQLSTATE -> 53300, Routine -> InitProcess, V -> FATAL, Message -> sorry, too many clients already, Severity -> FATAL)) at com.github.mauricio.async.db.postgresql.PostgreSQLConnection.onError(PostgreSQLConnection.scala:175) at com.github.mauricio.async.db.postgresql.codec.PostgreSQLConnectionHandler.channelRead0(PostgreSQLConnectionHandler.scala:206) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:343) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:336)

Is there a way to configure the amount of connections in the connection pool?

I'm not really sure on how to use the connections anyway (from the documentation).

At the moment, I have a global ConnectionPool[PostgreSQLConnection] and send of queries right from it. It looks like somehow the connections get recycled after a few seconds, but before that, I just receive exceptions like above.

I create the connection pool like this new ConnectionPool(factory, PoolConfiguration.Default)

domdorn commented 7 years ago

sorry, my fault... my provider was not a singleton