activate icon indicating copy to clipboard operation
activate copied to clipboard

HikariCP connections leak

Open akhodakivskiy opened this issue 11 years ago • 8 comments

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

akhodakivskiy avatar Mar 19 '14 05:03 akhodakivskiy

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.

brettwooldridge avatar Mar 24 '14 09:03 brettwooldridge

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.

akhodakivskiy avatar Mar 26 '14 04:03 akhodakivskiy

Did you find a way to configure calling shutdown() on reload?

brettwooldridge avatar Mar 26 '14 05:03 brettwooldridge

Unfortunately, looks like there isn't a way of executing code after the execution. Shutdown hooks don't work with sbt run.

fwbrasil avatar Mar 28 '14 10:03 fwbrasil

There is any news about this issue?? How can I contribute to solve it??

frossi85 avatar May 06 '14 04:05 frossi85

@frossi85 Could you investigate if there is a way of run arbitrary code during the sbt reload?

fwbrasil avatar May 06 '14 09:05 fwbrasil

I have same problem, application running on tomcat and it's eat all connection.

b0c1 avatar Aug 12 '14 13:08 b0c1

@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 } }

frossi85 avatar Apr 09 '15 18:04 frossi85