add logging to LARS so bugs can actually be found, see #2950
This commit is contained in:
parent
b6ad46e88c
commit
c5e10ad2df
2 changed files with 29 additions and 19 deletions
|
|
@ -236,6 +236,18 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit
|
|||
n * 1000.0 / (System.nanoTime - startTime).nanos.toMillis must be(4.4 plusOrMinus 0.3)
|
||||
}
|
||||
|
||||
"handle timeouts equal to multiple of wheel period" taggedAs TimingTest in {
|
||||
val timeout = 3200 milliseconds
|
||||
val barrier = TestLatch()
|
||||
import system.dispatcher
|
||||
val job = system.scheduler.scheduleOnce(timeout)(barrier.countDown())
|
||||
try {
|
||||
Await.ready(barrier, 5000 milliseconds)
|
||||
} finally {
|
||||
job.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
"survive being stressed without cancellation" taggedAs TimingTest in {
|
||||
val r = ThreadLocalRandom.current()
|
||||
val N = 100000
|
||||
|
|
@ -258,6 +270,10 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultSchedulerSpec extends AkkaSpec(SchedulerSpec.testConf) with SchedulerSpec {
|
||||
private val cancellables = new ConcurrentLinkedQueue[Cancellable]()
|
||||
|
||||
"A HashedWheelTimer" must {
|
||||
|
||||
|
|
@ -273,22 +289,7 @@ trait SchedulerSpec extends BeforeAndAfterEach with DefaultTimeout with Implicit
|
|||
job.cancel()
|
||||
}
|
||||
|
||||
"handle timeouts equal to multiple of wheel period" taggedAs TimingTest in {
|
||||
val timeout = 3200 milliseconds
|
||||
val barrier = TestLatch()
|
||||
import system.dispatcher
|
||||
val job = system.scheduler.scheduleOnce(timeout)(barrier.countDown())
|
||||
try {
|
||||
Await.ready(barrier, 5000 milliseconds)
|
||||
} finally {
|
||||
job.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultSchedulerSpec extends AkkaSpec(SchedulerSpec.testConf) with SchedulerSpec {
|
||||
private val cancellables = new ConcurrentLinkedQueue[Cancellable]()
|
||||
|
||||
def collectCancellable(c: Cancellable): Cancellable = {
|
||||
cancellables.add(c)
|
||||
|
|
@ -485,7 +486,7 @@ class LightArrayRevolverSchedulerSpec extends AkkaSpec(SchedulerSpec.testConfRev
|
|||
prb.ref ! ns
|
||||
try time += lbq.take()
|
||||
catch {
|
||||
case _: InterruptedException ⇒
|
||||
case _: InterruptedException ⇒ Thread.currentThread.interrupt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,9 +346,18 @@ class LightArrayRevolverScheduler(config: Config,
|
|||
try nextTick()
|
||||
catch {
|
||||
case t: Throwable ⇒
|
||||
val thread = threadFactory.newThread(this)
|
||||
try thread.start()
|
||||
finally timerThread = thread
|
||||
log.error(t, "exception on LARS’ timer thread")
|
||||
stopped.get match {
|
||||
case null ⇒
|
||||
val thread = threadFactory.newThread(this)
|
||||
log.info("starting new LARS thread")
|
||||
try thread.start()
|
||||
catch {
|
||||
case e: Throwable ⇒ log.error(e, "LARS cannot start new thread, ship’s going down!")
|
||||
}
|
||||
timerThread = thread
|
||||
case x ⇒ x success clearAll()
|
||||
}
|
||||
throw t
|
||||
}
|
||||
@tailrec final def nextTick(): Unit = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue