目标 我想更新(替换)数据库中的数据列表。注意 - 当我在大小 10 的列表上运行时,没有错误。但是当我运行超过 10 次时,我得到以下错误。有时如果运行不同的存储库类似的代码,那么我会面临同样的错误。
错误详情 -
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
我运行的代码 -
db.withPool { implicit session =>
EitherT.right[ApplicationError](repository.saveBulk(result)).value
}
在哪里 -
def withPool[A](f: SharedAsyncDBSession => Future[A]): Future[A]
询问 -
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(())
}