About the upgrade of rust canister

I recently wanted to try a container upgrade with a limit on the size of the container file footprint. As far as the test is concerned, when the file storage occupies 159MB, the container upgrade fails. The error message is: An error happened during the call: 5: Canister XXX-cai exceeded the instruction limit for single message execution. When the file storage occupies 140MB, it can be upgraded normally.
There are the following attempts.

  1. in dfx.json file add “args”: “–max-stable-pages-131072”, and call the rust library storage::stable_save() method.

  2. creat canister and then request a minimum of 8G storage space from IC network (actual test file size is 650MB) or so. The error is still the same: An error happened during the call: 5: Canister XXX-cai exceeded the instruction limit for single message execution.

Is there any way to upgrade the rust canister.

The storage size is not the bottleneck here - the error message says ‘instruction limit’ because what’s being limited is the instruction count. A pre_upgrade or post_upgrade hook has a low maximum number of cycles it can consume before the upgrade is rejected, and stable_save is hitting that limit. If you are storing a very large amount of data in the canister, consider using stable memory as the primary storage location (through ic_cdk::api::stable) instead of copying into and out of it on upgrade.

1 Like