sbt / sbt-remote-control

Create and manage sbt process using unicorns and forks
Other
74 stars 14 forks source link

Somehow we start executions in wrong order #213

Closed havocp closed 9 years ago

havocp commented 10 years ago

From https://s3.amazonaws.com/archive.travis-ci.org/jobs/36180244/log.txt (which may get deleted), we start infiniteLoop then compile but we try to run infiniteLoop after compile, in CanCancelTasks integration test. Here is a piece of the log.

[0m[info] CoreLogEvent(LogMessage(info,Set current project to test (in build file:/home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/)))
[info] CoreLogEvent(LogMessage(debug,> iflast shell))
[info] CoreLogEvent(LogMessage(debug,> server-send-ready-for-request))
[info] BuildLoaded()
[info] CoreLogEvent(LogMessage(debug,> server-handle-next-server-request))
[info] ExecutionWaiting(1,infiniteLoop,ClientInfo(3eb7e272-faa0-46eb-9baf-a4f96d392ca4,sbt-client-test,SbtClientTest unit test))
[info] ExecutionWaiting(2,compile,ClientInfo(3eb7e272-faa0-46eb-9baf-a4f96d392ca4,sbt-client-test,SbtClientTest unit test))
[info] ExecutionStarting(2)
[info] ExecutionFailure(2)
[info] ExecutionStarting(1)
[info] CoreLogEvent(LogMessage(debug,> infiniteLoop))
[info] CoreLogEvent(LogMessage(debug,Evaluating tasks: *:infiniteLoop))
[info] CoreLogEvent(LogMessage(debug,Running task... Cancel: sbt.server.ServerTaskCancellation@b2cd998, check cycles: false))
[info] CoreLogEvent(LogStdOut(
[info] ))
[info] CoreLogEvent(LogMessage(warn,Canceling execution...))
[info] TaskStarted(1,3,Some(AttributeKey[void]("infiniteLoop") in Scope(Build: file:/home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/, , Project: ProjectReference(file:/home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/,test))))
[info] CoreLogEvent(LogMessage(error,java.util.concurrent.RejectedExecutionException))
[info] CoreLogEvent(LogMessage(error,Use 'last' for the full log.))
[info] CoreLogEvent(LogMessage(debug,> server-post-command-error-handler))
[info] ExecutionFailure(1)
[info] CoreLogEvent(LogMessage(debug,> server-post-command-cleanup))
[error] -- Sequence did not match expected --
[error]  * CoreLogEvent(LogMessage(debug,> infiniteLoop))
[error]  * CoreLogEvent(LogMessage(debug,Evaluating tasks: *:infiniteLoop))
[info] log file is /home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/.sbtserver/connections/sbt-client-test-3eb7e272-faa0-46eb-9baf-a4f96d392ca4.log, you can uncomment some code in SbtClientTest.scala to dump this if you need to
[error]  * CoreLogEvent(LogMessage(debug,Running task... Cancel: sbt.server.ServerTaskCancellation@b2cd998, check cycles: false))
[error]  * CoreLogEvent(LogStdOut(
[error] ))
[error]  * CoreLogEvent(LogMessage(warn,Canceling execution...))
[error]  * TaskStarted(1,3,Some(AttributeKey[void]("infiniteLoop") in Scope(Build: file:/home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/, , Project: ProjectReference(file:/home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/,test))))
[error]  * CoreLogEvent(LogMessage(error,java.util.concurrent.RejectedExecutionException))
[error]  * CoreLogEvent(LogMessage(error,Use 'last' for the full log.))
[error]  * CoreLogEvent(LogMessage(debug,> server-post-command-error-handler))
[error]  * ExecutionFailure(1)
[info] CoreLogEvent(LogMessage(debug,> server-handle-next-server-request))
[info] Waiting for client to close
[info] ClosedEvent()
[info] Not executing runnable because we only run one thing: Runnable(onError(reconnecting=true, Connection closed))
[info] Waiting for client to close
[info] log file is /home/travis/build/sbt/sbt-remote-control/it-runner/target/integration-test/com-typesafe-sbtrc-it-loading-CanCancelTasks/scratch/test/.sbtserver/master.log, you can uncomment some code in SbtClientTest.scala to dump this if you need to
[error] Test failed: java.lang.AssertionError: No items matching compileStartedSecond
[error] java.lang.AssertionError: No items matching compileStartedSecond
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks$$anonfun$1.verifyOne$1(CanCancelTasks.scala:83)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks$$anonfun$1.verifySequence$1(CanCancelTasks.scala:88)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks$$anonfun$1.apply(CanCancelTasks.scala:137)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks$$anonfun$1.apply(CanCancelTasks.scala:26)
[error]    at com.typesafe.sbtrc.it.SbtClientTest$$anonfun$8.apply(SbtClientTest.scala:187)
[error]    at com.typesafe.sbtrc.it.SbtClientTest$$anonfun$8.apply(SbtClientTest.scala:161)
[error]    at com.typesafe.sbtrc.client.SimpleConnector$OpenListener$$anon$2.run(SimpleConnector.scala:151)
[error]    at com.typesafe.sbtrc.it.SbtClientTest$runOneThingExecutor$2$.runWhenReady(SbtClientTest.scala:144)
[error]    at com.typesafe.sbtrc.it.SbtClientTest$class.withSbt(SbtClientTest.scala:216)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks.withSbt(CanCancelTasks.scala:14)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks.delayedEndpoint$com$typesafe$sbtrc$it$loading$CanCancelTasks$1(CanCancelTasks.scala:26)
[error]    at com.typesafe.sbtrc.it.loading.CanCancelTasks$delayedInit$body.apply(CanCancelTasks.scala:14)
[error]    at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
[error]    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error]    at com.typesafe.sbtrc.it.IntegrationTest$$anonfun$run$1.apply(IntegrationTest.scala:32)
[error]    at com.typesafe.sbtrc.it.IntegrationTest$$anonfun$run$1.apply(IntegrationTest.scala:29)
[error]    at com.typesafe.sbtrc.it.package$.withContextClassloader(package.scala:12)
[error]    at com.typesafe.sbtrc.it.IntegrationTest.run(IntegrationTest.scala:29)
[error]    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
[error]    at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
[error]    at xsbt.boot.Launch$.run(Launch.scala:109)
[error]    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
[error]    at xsbt.boot.Launch$.launch(Launch.scala:117)
[error]    at xsbt.boot.Launch$.apply(Launch.scala:18)
[error]    at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error]    at xsbt.boot.Boot$.main(Boot.scala:17)
[error]    at xsbt.boot.Boot.main(Boot.scala)
[info] Error during sbt execution: java.lang.AssertionError: No items matching compileStartedSecond
[error]  [IT] com.typesafe.sbtrc.it.loading.CanCancelTasks result: FAILURE
havocp commented 10 years ago

This was caused by a short-circuit in the cancel case; when canceling, we removed a task from the queue and synthesized start/finish events for that task. I am removing that short-circuit and just always letting executions hit the ServerEngine, even if they are already canceled. This keeps events in order and reduces special cases.