FEATURE REQUEST: If pre_upgrade fails, revert canister to earlier state snapshot of before pre_upgrade ran and discard current pre_upgrade logic

Yes, I fully agree. It might be worth doing in a “debug” canister build for local testing.

Yes, I’d love this feature.

In my opinion, the main issue here is downloading and verifying a replica’s snapshot. Currently, there is no suitable mechanism for streaming gigabytes of data from the IC.

One approach that could work is introducing the fork system call or something similar. The workflow could be:

  1. Clone a canister at version 1 with a new ID. The clone could start its life in a Stopped state.
  2. Try to upgrade the clone to version 2.
  3. Try upgrading the clone to version 2 one more time to exercise the pre_upgrade hooks.
  4. If everything goes well, upgrade the primary instance. Drop the clone if you don’t need it anymore.
2 Likes