scala - Play slick session connection timeout -


i'm having problem session , connection handling in play slick 2.0.1 , play-slick 0.6.0.1

the error is

[sqlexception: timed out waiting free available connection.] [...] caused by: java.sql.sqlexception: timed out waiting free available connection.     @ com.jolbox.bonecp.defaultconnectionstrategy.getconnectioninternal(defaultconnectionstrategy.java:88) ~[bonecp.jar:na] [...] 

i have play base controller trait setting explicit session in 1 place

trait basecontroller extends controller secured {     import play.api.play.current     implicit def session: sessiondef = play.api.db.slick.db.withsession {         implicit session => {session}     } } 

then there /list action simple call userservice using explicit session:

object list extends basecontroller secured {   def index = isauthenticated { username =>     implicit request =>     userservice.findbyemail(username).map { user =>       ok(views.html.list.index(user))     }.getorelse(forbidden)   } } 

i have removed async actions don't think question duplicate of similar questions: play slick , async - race condition? or scala play 2.2 slick 1.0.1 - future { try {...} } timed out waiting free available connection

the issue occurs after reloading action 10 times.

obviously i'm doing wrong in session handling of slick - there examples of slick 2 session handling in playframework? best practice that?

edit: 1 possible source of issue might object use holding tablequeries

object models {     val users = tablequery[users]     val mailinglists = tablequery[mailinglists]     val mailinglistmemberships = tablequery[mailinglistmemberships] } 

if may source of problem, place put these references? main reason object reference these instances in foreign keys of table definition (similar http://slick.typesafe.com/doc/2.0.1/schemas.html#constraints)

edit: here's code findbyemail - don't think matters. seems same behavior , problem in queries.

def findbyemail(email: string)(implicit session: session): option[user]   = models.users.filter(_.email === email).firstoption 

i'd thankful hint right direction.

i have faced same problem.it seems application not getting connection connection pooling.so have used configuration:

db.default.partitioncount=1   db.default.maxconnectionsperpartition=20  db.default.minconnectionsperpartition=10  db.default.acquireincrement=1     db.default.acquireretryattempts=5  db.default.acquireretrydelay=5 seconds  db.default.acquireretrydelay=5 seconds db.default.idlemaxage=10 minute  db.default.idleconnectiontestperiod=5 minutes  db.default.initsql="select 1"  db.default.maxconnectionage=1 hour 

then never error(timed out waiting free available connection).(my application deployed on heroku postgres database)


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -