Skip to content

HikariCP connections leak #116

Open
Open

Description

@akhodakivskiy

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

Activity

  1. brettwooldridge commented on Mar 24, 2014

    @brettwooldridge

    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.

  2. akhodakivskiy commented on Mar 26, 2014

    @akhodakivskiy
    ContributorAuthor

    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.

  3. brettwooldridge commented on Mar 26, 2014

    @brettwooldridge

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

  4. fwbrasil commented on Mar 28, 2014

    @fwbrasil
    Owner

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

  5. frossi85 commented on May 6, 2014

    @frossi85

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

  6. fwbrasil commented on May 6, 2014

    @fwbrasil
    Owner

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

  7. b0c1 commented on Aug 12, 2014

    @b0c1
    Contributor

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

  8. frossi85 commented on Apr 9, 2015

    @frossi85

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions