#621 ✓resolved
Cyril Bonté

DB Pool leak on reload

Reported by Cyril Bonté | March 1st, 2011 @ 03:19 PM | in 1.2

As a standalone application in DEV mode or embedded in a servlet container like Tomcat, Play doesn't free its connection pool on configuration reload (or context reload).

Framework version: 1.1.1
Platform you're using: linux

Reproduction steps:
1. Download a fresh play-1.1.1 archive and unzip it.
2. Go into the play root directory and execute the script attached that show the issue.

The script creates a db-pool-leak application which requires an access to a local mysql instance with 2 databases 'db1' and 'db2' and a user 'test' authentified with the password 'test' (Feel free to customize this, the goal is to force a new pool creation each time the configuration is reloaded).

Details:
Play should destroy its c3p0 pool on configuration reload if the pool configuration has changed and on application stop.
Please have a look the following pull request : https://github.com/playframework/play/pull/93

In the proposed patch, a workaround is also added to apply he same behaviour on JNDI datasources (by adding a "destroyMethod" property) to let the user decide if the pool should be destroyed (and how) after a context is reloaded.

Output example of the script attached :
Waiting 5s before the test...
Loop 1...
===> c3p0 threads : 3 Loop 2...
===> c3p0 threads : 6 Loop 3...
===> c3p0 threads : 9 Loop 4...
===> c3p0 threads : 12 Loop 5...
===> c3p0 threads : 15 Loop 6...
===> c3p0 threads : 15 Loop 7...
===> c3p0 threads : 15 Loop 8...
===> c3p0 threads : 18 Loop 9...
===> c3p0 threads : 18 Loop 10...
===> c3p0 threads : 18 Loop 11...
===> c3p0 threads : 18 Loop 12...
===> c3p0 threads : 18 Loop 13...
===> c3p0 threads : 18 Loop 14...
===> c3p0 threads : 18 Loop 15...
===> c3p0 threads : 21 Loop 16...
===> c3p0 threads : 21 Loop 17...
===> c3p0 threads : 21 Loop 18...
===> c3p0 threads : 24 ...

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2>Play framework</h2>

Play makes it easier to build Web applications with Java. It is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Learn more on the <a href="http://www.playframework.org">http://www.playframework.org</a> website.<br><br>

<h2>Source code is hosted on github</h2>Check out our repository at <a href="http://github.com/playframework/play">http://github.com/playframework/play</a><br><br>

<h2>Contributing, creating a patch</h2> Please read the <a href="http://play.lighthouseapp.com/projects/57987/contributor-guide">contributor guide</a><br><br>

<h2>Reporting Security Vulnerabilities</h2> Since all bug reports are public, please report any security vulnerability directly to <em>guillaume dot bort at gmail dot com</em>.<br><br>

<h2>Creating a bug report</h2> Bug reports are incredibly helpful, so take time to report bugs and request features in our ticket tracker. We’re always grateful for patches to Play’s code. Indeed, bug reports with attached patches will get fixed far quickly than those without any.<br><br>

Please include as much relevant information as possible including the exact framework version you're using and a code snippet that reproduces the problem.<br><br>

Don't have too much expectations. Unless the bug is really a serious "everything is broken" thing, you're creating a ticket to start a discussion. Having a patch (or a branch on Github we can pull from) is better, but then again we'll only pull high quality branches that make sense to be in the core of Play.

Attachments

Referenced by

Pages