-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task slick.backend.DatabaseComponent rejected from java.util.concurrent.ThreadPoolExecutor #1183
Comments
I'm getting this exception thrown in specs. |
I caught this problem when I run |
I'm getting same exception when running specs. Using |
I caught this problem when I use transaction like db.run(action.transactionally). if I remove the transactionally, it will be fine. |
Same here: large number of transactional DBIOActions in quick succession triggered the same exception. Removing the .transactionally makes the problem go away, but I'd like to keep the transactional guarantee. |
This is the intended behavior. It happens when too many actions queue up. You can increase the However, I have no idea why it would behave differently for transactional vs auto-commit actions. Maybe the transactional versions are simply slower in the database so you reach the limit sooner? Slick prioritizes all follow-on actions (e.g. the second part of an |
@szeiger I'm having the same issue, and I'd like to change the rejection policy. I tried with |
I think this issue is related to #1274 and was closed prematurely. In that other issue a quick succession of transactional DBIO actions causes the connection pool to be completely consumed and the slick executor threads are blocked during the connection timeout period. So, in my case I first see a couple of SqlTimeoutExceptions followed by an onslaught of RejectedExecutionException. |
Did this ever get resolved? I am seeing the same issue when unit testing with Specs, using Play 2.4 and Play-Slick 1.1.1 FYI I am using a FakeApplication in my tests, which may be where the error comes from as this doesn't happen when running via play normally
|
I have this very same issue. In my case, I've implemented a batch migration script using standard streams just because of the back-pressure feature, so I was expecting to avoid this kind of errors. Here you have the implementation in order to read from a huge table and insert the records in a destination database. Both of them running MySQL: val query = for {
c <- SourceTableRow
p <- SourceTable2Row if c.foreignKey === p.primaryKey
} yield (c, p.otherField)
def enableStream(statement: java.sql.Statement): Unit = {
statement match {
case s: com.mysql.jdbc.StatementImpl => s.enableStreamingResults()
case _ =>
}
}
val publisher = sourceDb.stream(query.result.withStatementParameters(statementInit = enableStream))
val source = Source.fromPublisher(publisher)
val saveResult = source.runForeach {
case (sourceTable1Row, sourceTable2Field) =>
val model = DestinationModel(
// ...
)
val result = destinationDb.run(Persistence.model += model) As I said, I was expecting to have the back-pressure feature by default. Am I wrong? how do I have to deal with this? If I increase the allowed amount of task in queue, I'll be only moving the problem forward because it's a matter of time that the script reaches this limitation :-/ EDIT: I've found this in the Slick homepage:
So I think that the back-pressure behavior implemented by Slick is not the kind of back-pressure behaviour I was expecting (tell the publisher to wait while it's processing the current received rows). |
@JavierCane I think execution based on consuming a Reactive Stream instead of calling |
Have the same with my specs: just after |
If you use |
@RichyHBM how did you overcome your issue? having the same problem on specs with fake application...
|
instead of running the fake application for each test I'm using seems to work (because it's always the same application/db connection I suppose) - in case someone needs a workaround |
@d6y do you think this could be solved by better documentation? Reopening this as a documentation issue for now. |
@pedrorijo91 That is pretty much how I solved it, just have the 1 play application running for all of your tests |
Yeah, |
the problem is that the test database (H2) is dirty between each test on the test suite...but I guess I can clear (all) tables, or split into several test suite |
Yeah, I've done my small |
With Slick 3.2 (hikaricp, default settings) we had this:
and it was not recovering from it, had to restart app server. Is there a cure? :) |
+1 |
I'm also seeing this when running my tests, very predictably. |
We are also running into this. Is it already supported to increase the |
I think I found the answer is yes at http://slick.lightbend.com/doc/3.2.1/api/index.html#slick.jdbc.JdbcBackend$DatabaseFactoryDef |
I'm using slick 3.0.0 version.
Exception:
As i think, this problem occurred due to lack of free threads in thread pool but i have no idea how to increase them. In hikariCP for my computer spec i need exactly 20 threads in pool.
Any recommendations?
The text was updated successfully, but these errors were encountered: