question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race condition with Slick in tests.

See original GitHub issue

I have the following “errors” in my tests:

2018-05-04 08:40:05,007 WARN  slick.basic.BasicBackend.stream - Error scheduling synchronous streaming
java.util.concurrent.RejectedExecutionException: Task slick.basic.BasicBackend$DatabaseDef$$anon$3@32476d51 rejected from slick.util.AsyncExecutor$$anon$2$$anon$1@25475727[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 150]
	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
	at slick.util.AsyncExecutor$$anon$2$$anon$3.execute(AsyncExecutor.scala:161)
	at slick.basic.BasicBackend$DatabaseDef.scheduleSynchronousStreaming(BasicBackend.scala:301)
	at slick.basic.BasicBackend$DatabaseDef.scheduleSynchronousStreaming$(BasicBackend.scala:299)
	at slick.jdbc.JdbcBackend$DatabaseDef.scheduleSynchronousStreaming(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef.streamSynchronousDatabaseAction(BasicBackend.scala:294)
	at slick.basic.BasicBackend$DatabaseDef.streamSynchronousDatabaseAction$(BasicBackend.scala:292)
	at slick.jdbc.JdbcBackend$DatabaseDef.streamSynchronousDatabaseAction(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef.slick$basic$BasicBackend$DatabaseDef$$runInContextInline(BasicBackend.scala:239)
	at slick.basic.BasicBackend$DatabaseDef.runInContextSafe(BasicBackend.scala:147)
	at slick.basic.BasicBackend$DatabaseDef.runInContext(BasicBackend.scala:141)
	at slick.basic.BasicBackend$DatabaseDef.runInContext$(BasicBackend.scala:140)
	at slick.jdbc.JdbcBackend$DatabaseDef.runInContext(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef$$anon$1.subscribe(BasicBackend.scala:117)
	at akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary.preStart(ActorGraphInterpreter.scala:117)
	at akka.stream.impl.fusing.GraphInterpreter.init(GraphInterpreter.scala:295)
	at akka.stream.impl.fusing.GraphInterpreterShell.init(ActorGraphInterpreter.scala:554)
	at akka.stream.impl.fusing.ActorGraphInterpreter.tryInit(ActorGraphInterpreter.scala:676)
	at akka.stream.impl.fusing.ActorGraphInterpreter.preStart(ActorGraphInterpreter.scala:724)
	at akka.actor.Actor.aroundPreStart(Actor.scala:528)
	at akka.actor.Actor.aroundPreStart$(Actor.scala:528)
	at akka.stream.impl.fusing.ActorGraphInterpreter.aroundPreStart(ActorGraphInterpreter.scala:667)
	at akka.actor.ActorCell.create(ActorCell.scala:654)
	at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:525)
	at akka.actor.ActorCell.systemInvoke(ActorCell.scala:547)
	at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
	at akka.dispatch.Mailbox.run(Mailbox.scala:223)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
2018-05-04 08:40:05,401 WARN  slick.basic.BasicBackend.stream - Error scheduling synchronous streaming
java.util.concurrent.RejectedExecutionException: Task slick.basic.BasicBackend$DatabaseDef$$anon$3@491ea42e rejected from slick.util.AsyncExecutor$$anon$2$$anon$1@25475727[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 150]
	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063)
	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830)
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379)
	at slick.util.AsyncExecutor$$anon$2$$anon$3.execute(AsyncExecutor.scala:161)
	at slick.basic.BasicBackend$DatabaseDef.scheduleSynchronousStreaming(BasicBackend.scala:301)
	at slick.basic.BasicBackend$DatabaseDef.scheduleSynchronousStreaming$(BasicBackend.scala:299)
	at slick.jdbc.JdbcBackend$DatabaseDef.scheduleSynchronousStreaming(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef.streamSynchronousDatabaseAction(BasicBackend.scala:294)
	at slick.basic.BasicBackend$DatabaseDef.streamSynchronousDatabaseAction$(BasicBackend.scala:292)
	at slick.jdbc.JdbcBackend$DatabaseDef.streamSynchronousDatabaseAction(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef.slick$basic$BasicBackend$DatabaseDef$$runInContextInline(BasicBackend.scala:239)
	at slick.basic.BasicBackend$DatabaseDef.runInContextSafe(BasicBackend.scala:147)
	at slick.basic.BasicBackend$DatabaseDef.runInContext(BasicBackend.scala:141)
	at slick.basic.BasicBackend$DatabaseDef.runInContext$(BasicBackend.scala:140)
	at slick.jdbc.JdbcBackend$DatabaseDef.runInContext(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef$$anon$1.subscribe(BasicBackend.scala:117)
	at akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary.preStart(ActorGraphInterpreter.scala:117)
	at akka.stream.impl.fusing.GraphInterpreter.init(GraphInterpreter.scala:295)
	at akka.stream.impl.fusing.GraphInterpreterShell.init(ActorGraphInterpreter.scala:554)
	at akka.stream.impl.fusing.ActorGraphInterpreter.tryInit(ActorGraphInterpreter.scala:676)
	at akka.stream.impl.fusing.ActorGraphInterpreter.preStart(ActorGraphInterpreter.scala:724)
	at akka.actor.Actor.aroundPreStart(Actor.scala:528)
	at akka.actor.Actor.aroundPreStart$(Actor.scala:528)
	at akka.stream.impl.fusing.ActorGraphInterpreter.aroundPreStart(ActorGraphInterpreter.scala:667)
	at akka.actor.ActorCell.create(ActorCell.scala:654)
	at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:525)
	at akka.actor.ActorCell.systemInvoke(ActorCell.scala:547)
	at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
	at akka.dispatch.Mailbox.run(Mailbox.scala:223)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

It does not break my tests, it’s just ugly in the tests results.

Does anyone else have this problem ?

I use Lagom 1.4 with Scala.

The Slick people opinion is that it’s a race condition (see: https://github.com/slick/slick/issues/1892#issuecomment-386555870) but I don’t know how to debug that.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
guizmaiicommented, May 29, 2018

@ignasi35 we’re using Lagom 1.4.5 and if I remember well the problem always happened in the Lagom 1.4 branch.

I don’t remember if the problem exists in Lagom 1.3.

1reaction
kflorencecommented, Sep 5, 2018

@igorbolic thanks! confirmed that doing the above works with Lagom 1.4.5 and Scala:

  override protected def afterAll(): Unit = {
    TestKit.shutdownActorSystem(server.actorSystem)
    server.stop()
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoiding race condition in postgres updates using slick
The code above has a race condition - if two threads run this in parallel they might both read the same count, and...
Read more >
Race condition between shutting down a stream and executing ...
When testing #4417 with #4516 as the implementation I observed this race condition ... runSynchronousDatabaseAction$(BasicBackend.scala:263) at slick.jdbc.
Read more >
Reproducing Race Conditions in Tests
A race condition occurs when two or more threads of execution modify the same data simultaneously. This simultaneity may be truly concurrent ...
Read more >
Indy 500 testing paused after three spins in warmup lane
The yet-to-be-diagnosed track issue at pit exit on the warmup lane at IMS led to three uncharacteristic spins from three veteran drivers (three ......
Read more >
Racing slick
Slick tyres are not suitable for use on common road vehicles, which must be able to operate in all weather conditions. They are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found