Heroku POSTGRESQL - “角色连接太多”错误

时间:2022-10-15 20:00:40

I've set up a connection from localhost to the Dev database on Heroku (as described in: Errors in evolutions on Heroku) and I am receving the following error after trying to apply evolutions a couple of times:

我已经建立了从localhost到Heroku上的Dev数据库的连接(如:Heroku中的evolutions中的错误所述),并且在尝试应用evolutions几次之后我收到了以下错误:

SQLException: Unable to open a test connection to the given database. JDBC url = [URL], username = null. Terminating connection pool. 
Original Exception: org.postgresql.util.PSQLException: FATAL: too many connections for role "ntnkypawxazhwo"
    at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:469) 
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:110) 
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64) 
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:123) 
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:28) 
    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:20) 
    at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30) 
    at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:22) 
    at org.postgresql.Driver.makeConnection(Driver.java:391) 
    at org.postgresql.Driver.connect(Driver.java:265) 
    at play.utils.ProxyDriver.connect(ProxyDriver.scala:9) 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) 
    at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:305) 
    at com.jolbox.bonecp.BoneCPDataSource.maybeInit(BoneCPDataSource.java:150) 
    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112) 
    at play.api.db.DBApi$class.getConnection(DB.scala:64) 
    at play.api.db.BoneCPApi.getConnection(DB.scala:273) 
    at play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:306) 
    at play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:284) 
    at play.api.db.evolutions.OfflineEvolutions$.applyScript(Evolutions.scala:452) 
    at play.core.ReloadableApplication.handleWebCommand(ApplicationProvider.scala:175) 
    at play.core.server.Server$$anonfun$getHandlerFor$1.apply(Server.scala:86) 
    at play.core.server.Server$$anonfun$getHandlerFor$1.apply(Server.scala:86) 
    at scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:110) 
    at scala.util.control.Exception$Catch$$anonfun$either$1.apply(Exception.scala:110) 
    at scala.util.control.Exception$Catch.apply(Exception.scala:88) 
    at scala.util.control.Exception$Catch.either(Exception.scala:110) 
    at play.core.server.Server$class.getHandlerFor(Server.scala:86) 
    at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:38) 
    at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(PlayDefaultUpstreamHandler.scala:226) 
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75) 
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558) 
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777) 
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) 
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:522) 
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501) 
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438) 
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75) 
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558) 
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553) 
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) 
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) 
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343) 
    at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274) 
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194) 
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102) 
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source)

Dev databases have a fixed number of available connections (20 or so). How can I make sure I am properly closing my connections?

开发人员数据库具有固定数量的可用连接(大约20个)。我怎样才能确保正确关闭我的连接?

1 个解决方案

#1


6  

You can use the JDBC settings of Play to reduce the number of connections. Try setting only 1 partition to start:

您可以使用Play的JDBC设置来减少连接数。尝试仅设置1个分区以启动:

db.default.partitionCount=1

and keep tweaking to limit time and number of connections per partition.

并不断调整以限制每个分区的时间和连接数。

#1


6  

You can use the JDBC settings of Play to reduce the number of connections. Try setting only 1 partition to start:

您可以使用Play的JDBC设置来减少连接数。尝试仅设置1个分区以启动:

db.default.partitionCount=1

and keep tweaking to limit time and number of connections per partition.

并不断调整以限制每个分区的时间和连接数。