Will an upgrade timer

if I have a timer that spawns a long running task that on average takes 10 minutes to complete and an upgrade is triggered at minute 5 ( half way through ). will my long running task be terminated half way through?

Thanks,

Yes.

The pan industrial timer tool fixes this if you are using motoko.

Thanks, although we use Rust so I can’t use PanIndustrial timers.

taking a glancing look at the timer repo you linked though, I’m not concerned about timers restarting, that part is easy and the timer in this case is almost irrelevant . What i want to know is
** If the timer spawns a task ( not a timer ), e.g ic_cdk::spawn(some_async_function), will some_async_function get terminated at any point if an upgrade call is sent to the canister?**

I believe that all outstanding calls have to resolve before an upgrade will run. You could actually put yourself in an infinite loop and cause your canister to Become Un upgradable.

In my particular case, the task is spawned when a timer hits a particular interval. Because an update call didn’t trigger the task to run am i correct in assuming the upgrade call will not wait for the task to complete?

I dont really want my scheduled task to be interrupted by an upgrade call. So i guess i could do the following

  • move all the code from the long running task to a update method.
  • have the timer call the method

because an update call is triggered, the canister would have to wait for the upgrade call to complete correct?

I know i mentioned my long running task is 10 minutes but that was just for demonstrative purposes. My task only takes around 10 - 20 seconds to complete so this is within the limitaitons of an update call.

A timer message is in an update call
In the perspective of the replica.

I believe it is recommended to stop the canister before upgrading.

The IC will reject all calls to a stopping canister, indicating that the canister is stopping. Responses to a stopping canister are processed as usual. When all outstanding responses have been processed (so there are no open call contexts), the canister status is changed to stopped and the management canister responds to the caller of the stop_canister request.

Just curious, is it possible to create an sns proposal to stop, upgrade and start the target canister?

1 Like

Yes this is the basic function and purpose of the sns. If you look at the upgrade proposal did files you’ll see the install options include waiting for the canister to stop and upgrade/reinstall options.

These are harder to find than they should be. I’m in a mobile, but just try to find the governance canister for any sns and check out the proposal types on the ic dashboard.