Restart sources


#1

I’m trying to understand the behaviour of using RestartSource.withBackoff.

It looks like one of my sources is restarted more times than the maxRestart count. It looks like this is happening becaues in RestartWithBackoffLogic.maxRestartsReached() has a resetDeadline that can pass in which the restartCount is reset to 0.

This isn’t documented in the documentation, so I’ve been trying to understand what triggers this behaviour. It looks like if I have a minBackof of 1 second, but sometimes the source takes longer than 1 second to fail, the restart count will repeated be reset to 0 and hence the source will be restarted forever.

Does anyone have more insights into this behaviour? If I’m correct about the behaviour, and if so, why does it behave this way and should it be in the API documentation?


(Martynas Mickevičius) #2

The behaviour that you describe is the intended one. From the api doc of the RestartSource.withBackoff:

  • @param maxRestarts the amount of restarts is capped to this amount within a time frame of minBackoff. Passing 0 will cause no restarts and a negative number will not cap the amount of restarts.

The maxRestarts parameter is meant to prevent rapid restarts until the exponential backoff gets large enough. So it controls the maximum amount of restarts that can happen in a time frame equal to the one specified in the minBackoff parameter.


#3

So, it sounds like there’s no way to specify an absolute cap on the max number of restarts, and so it could potentially be restarting forever? It sounds like this is different than the Backoff strategy for actors.

I’m a bit confused why maxRestarts would apply to the number of restarts within a minBackoff interval:

   * @param minBackoff minimum (initial) duration until the child actor will
   *   started again, if it is terminated

It sounds like the source shouldn’t be restarted sooner than minBackoff. So why would we have 1 or more restarts within that time frame?