...
private def addPendingEndedEvent(fp: FreePreview, data: Data): Unit = {
trace(s"FreePreviewScheduler.addPendingEndedEvent with fp: $fp.")
for (i <- fp.interval) setTimer(fp.id.toString, FreePreviewEndedTimerEvent(
fp.id, data.updateId), fromNow(i.getEnd), false)
}
private def fromNow(time: DateTime) = {
val fromNowDuration = (time.getMillis - System.currentTimeMillis).milliseconds
trace(s"FreePreviewScheduler.fromNow: now to $time is $fromNowDuration")
fromNowDuration
}
We're running with akka 2.2.1.
I'll work on a unit test to reproduce this and will post it here.
tickNanos here is akka.scheduler.tick-duration config value in nanosecond form. The default - which we are using - is 50 milliseconds (50000 nanoseconds). I determined that our delays - which as I mentioned can go several months for some tasks - could indeed have a nanosecond value that when divided by 50000 would still cause a 32 bit int value to overflow its sign bit and go negative. Changing the akka.scheduler.tick-duration to a larger value - we tried 500ms - caused the issue to go away. Clearly for such a task as this, that value is fine, as is the work around we put in place (to cap the delay at a shorter maximum value and requeue the timer if we have not yet reached the timer for the particular event). But I wanted to make you guys aware of this issue, if it is indeed an issue (or perhaps to point me to where I might be going wrong - not an infrequent occurrence! :-) ).