I'm not sure what this is called a race condition. However, it seems to me that you are right that something is wrong here. A session may be more invalid when the future executes code.
It would be better to invert the execution and query the database session from the future:
Async { Future { DB.withSession{ s:scala.slick.session.Session => r( RequestWithDbSession(request, s) ) } } }
source share