jrudolph commented on code in PR #4:
URL: https://github.com/apache/incubator-pekko/pull/4#discussion_r1012669094
##########
akka-stream/src/main/scala/akka/stream/impl/Timers.scala:
##########
@@ -275,11 +275,15 @@ import akka.stream.stage._
val now = System.nanoTime()
// Timer is reliably cancelled if a regular element arrives first.
Scheduler rather schedules too late
// than too early so the deadline must have passed at this time.
- assert(
- now - nextDeadline >= 0,
Review Comment:
> Maybe I'm wrong, but if you can go back in time with `System.nanoTime`, a
lot of functionality breaks in projects.
Agreed. Though, monotonicity does not seem to be mentioned in its javadoc,
so there's some wiggle room in the JVM to do something else. It seems that the
JVM uses a monotonic clock source if available or fall back on whatever is
available. See
https://stackoverflow.com/questions/51344787/in-what-cases-clock-monotonic-might-not-be-available
The original ticket mentions two scenarios, a Kubernetes App on GCP and
Windows. Let's ignore Windows. One issue might be that people use weird base
images in their docker images (like alpine which has several edge cases people
might not expect).
> My assumption is that this issue happens because the timer woke up
_earlier_ for some reason. It's like when you do `Object.wait(1000)`
([link](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait(long))),
but you're not guaranteed `1000 millis`, as it can wake up earlier, so you
have to check, and sleep some more if needed.
Timers use the `LightArrayRevolverScheduler` which should not run tasks
before the scheduled time (i.e. in the loop the current `nanoTime` is checked
against the target time for a tick and otherwise more sleeping is added.
> If the timer simply wakes up earlier (the delay isn't guaranteed), then
there's no need for the `log.warning`, since this is a happy path.
In any case, it's a path we can handle (and do after this change), so let's
demote to INFO or even DEBUG.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]