Objective I want to update(replace) list of data in database. Note - When i run on list of size 10 there is no error. But when i run more than 10 i get below error. Sometime if run different repository similar code then i face same error.
Error details -
error = com.github.jasync.sql.db.pool.PoolExhaustedException: There are no objects available and the waitQueue is full, errorCause = com.github.jasync.sql.db.pool.PoolExhaustedException: There are no objects available and the waitQueue is full
Code which i run -
db.withPool { implicit session =>
EitherT.right[ApplicationError](repository.saveBulk(result)).value
}
where -
def withPool[A](f: SharedAsyncDBSession => Future[A]): Future[A]
Query -
override def saveBulk(myList: Seq[MyCaseClass])(
implicit session: AsyncDBSession): Future[Unit] =
if (myList.nonEmpty) {
myList.map { m =>
withSQL {
insert
.into(MyTable)
.namedValues(autoNamedValues(m, column))
.onConflictUpdateNamed(SQLSyntax.createUnsafely("id1, id2, datetime"))(
autoNamedValues(m, column))
}.execute.future().map(_ => ())
}.head
} else {
Future.successful(())
}