Play slick and Async - is it a race condition?

回眸只為那壹抹淺笑 提交于 2019-11-29 07:54:52

I am not sure if that is called a race condition. However to me it seems that you are correct that something is wrong here. The session might no longer be valid when the future executes the code.

It would be better to invert the execution and request a database session from within the future:

Async {
  Future {
    DB.withSession{ s:scala.slick.session.Session =>
      r( RequestWithDbSession(request, s) )
    }
  }
}

I think your are right and fix suggested by EECOLOR looks correct. We are tracking this in a ticket: https://github.com/freekh/play-slick/issues/81

Thx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!