He-Pin opened a new pull request, #3111:
URL: https://github.com/apache/pekko/pull/3111

   ### Motivation
   
   `IdleInject`, `Idle`, `BackpressureTimeout`, and `IdleTimeoutBidi` all 
initialize `nextDeadline` at `GraphStageLogic` construction time 
(`System.nanoTime + timeout.toNanos`), not in `preStart()`. If materialization 
takes longer than the configured timeout, the first timer check or `onPull` 
triggers a spurious idle injection/timeout even though no actual idle period 
has occurred.
   
   This is a correctness issue: the deadline should be measured from when the 
stage actually starts processing, not from when its logic object is constructed.
   
   ### Modification
   
   Move `nextDeadline` initialization from construction time to `preStart()` in 
all four timer stages:
   
   - **`IdleInject`** (`Timers.scala:243`): `nextDeadline = 0L` at 
construction, set in `preStart()`
   - **`Idle`** (`Timers.scala:108`): same pattern
   - **`BackpressureTimeout`** (`Timers.scala:136`): same pattern
   - **`IdleTimeoutBidi`** (`Timers.scala:174`): same pattern
   
   ### Result
   
   Timer stages no longer risk spurious timeouts from delayed materialization. 
The deadline is always measured from the actual stream start time.
   
   ### Tests
   
   - `sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.scaladsl.FlowIdleInjectSpec"` — 10/10 passed
   - `sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.impl.TimeoutsSpec"` — 25/25 passed
   - `sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.javadsl.SourceTest"` — 109/109 passed
   - `sbt "stream-tests / Test / testOnly 
org.apache.pekko.stream.javadsl.FlowTest"` — 88/88 passed
   
   Directional regression tests added:
   - `"not inject idle element before timeout elapses from stream start"` 
(FlowIdleInjectSpec)
   - `"not fail before timeout elapses from stream start"` (TimeoutsSpec — 
IdleTimeout, BackpressureTimeout, IdleTimeoutBidi)
   
   ### References
   
   Fixes #3105


-- 
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]

Reply via email to