last night Play suddently could no longer connect to database (PostGreSQL on the same EC2 instance).
23:57:31.996 [BoneCP-pool-watch-thread] ERROR com.jolbox.bonecp.hooks.AbstractConnectionHook {1}
-Failed to acquire connection Sleeping for 5000ms and trying again. Attempts left: 10. Exception: null
Sometimes, the error thrown is different :
01:21:05.920 [BoneCP-pool-watch-thread] ERROR com.jolbox.bonecp.PoolWatchThread {1} -Error in trying to obtain a connection. Retrying in 5000ms
org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections
It retried every 5 seconds without success. I restarted Play and it reconnected well.
This happens twice this week.
I thought about auto restart. Do you know a tool for that ? Or any other idea ?
EDIT I updated BoneCP by updating dependencies in Build.scala :
"com.google.guava" % "guava" % "14.0-rc1",
"org.slf4j" % "slf4j-api" % "1.7.5",
"com.jolbox" % "bonecp" % "0.8.0-rc1",
"org.reflections" % "reflections" % "0.9.8"
But now I regularly get this error telling it can't close connection. So it reaches the max number of connections again.
-Error closing Connection org.postgresql.util.PSQLException: Cannot change transaction read-only property in the middle of a transaction. at org.postgresql.jdbc2.AbstractJdbc2Connection.setReadOnly(AbstractJdbc2Connection.java:617) ~[postgresql.postgresql-9.1-901-1.jdbc4.jar:na]