You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Activate 1.5-M4
Can also be reproduced with this example. Follow the steps to create database, and then just tun sbt, and then run twice run and run. First execution will finish properly, but apparently won't release connections. Second run will fail:
22:53:31.251 [run-main-1] ERROR com.zaxxer.hikari.HikariPool - Maximum connection creation retries exceeded: FATAL: remaining connection slots are reserved for non-replication superuser connections
org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections
HikariCP itself has a shutdown() that should be wired up when a container reloads. I know how to do it in Spring and Tomcat, but I'm not familiar with the Activate framework ... so I'm now sure how you do it but thats the gist of it.
Another bit of information - with Activate 1.4.1 which uses c3p0 I'm experiencing the same issue, although it takes quite a few reloads to reach connections limit.
How can I take action when the project is loaded or unloaded?
The single, global setting onLoad is of type State => State (see State and actions) and is executed once, after all projects are built and loaded. There is a similar hook onUnload for when a project is unloaded. Project unloading typically occurs as a result of a reload command or a set command. Because the onLoad and onUnload hooks are global, modifying this setting typically involves composing a new function with the previous value. The following example shows the basic structure of defining onLoad:
// Compose our new function 'f' with the existing transformation.
{
val f: State => State = ...
onLoad in Global := {
val previous = (onLoad in Global).value
f compose previous
}
}
Example of project load/unload hooks
The following example maintains a count of the number of times a project has been loaded and prints that number:
{
// the key for the current count
val key = AttributeKeyInt
// the State transformer
val f = (s: State) => {
val previous = s get key getOrElse 0
println("Project load count: " + previous)
s.put(key, previous + 1)
}
onLoad in Global := {
val previous = (onLoad in Global).value
f compose previous
}
}
Activity
brettwooldridge commentedon Mar 24, 2014
HikariCP itself has a shutdown() that should be wired up when a container reloads. I know how to do it in Spring and Tomcat, but I'm not familiar with the Activate framework ... so I'm now sure how you do it but thats the gist of it.
akhodakivskiy commentedon Mar 26, 2014
Another bit of information - with Activate 1.4.1 which uses c3p0 I'm experiencing the same issue, although it takes quite a few reloads to reach connections limit.
brettwooldridge commentedon Mar 26, 2014
Did you find a way to configure calling
shutdown()on reload?fwbrasil commentedon Mar 28, 2014
Unfortunately, looks like there isn't a way of executing code after the execution. Shutdown hooks don't work with sbt run.
frossi85 commentedon May 6, 2014
There is any news about this issue?? How can I contribute to solve it??
fwbrasil commentedon May 6, 2014
@frossi85 Could you investigate if there is a way of run arbitrary code during the sbt reload?
b0c1 commentedon Aug 12, 2014
I have same problem, application running on tomcat and it's eat all connection.
frossi85 commentedon Apr 9, 2015
@fwbrasil This is what you ask me??
from: http://www.scala-sbt.org/0.13.5/docs/faq.html
How can I take action when the project is loaded or unloaded?
The single, global setting onLoad is of type State => State (see State and actions) and is executed once, after all projects are built and loaded. There is a similar hook onUnload for when a project is unloaded. Project unloading typically occurs as a result of a reload command or a set command. Because the onLoad and onUnload hooks are global, modifying this setting typically involves composing a new function with the previous value. The following example shows the basic structure of defining onLoad:
// Compose our new function 'f' with the existing transformation.
{
val f: State => State = ...
onLoad in Global := {
val previous = (onLoad in Global).value
f compose previous
}
}
Example of project load/unload hooks
The following example maintains a count of the number of times a project has been loaded and prints that number:
{
// the key for the current count
val key = AttributeKeyInt
// the State transformer
val f = (s: State) => {
val previous = s get key getOrElse 0
println("Project load count: " + previous)
s.put(key, previous + 1)
}
onLoad in Global := {
val previous = (onLoad in Global).value
f compose previous
}
}