# About the upgrade of rust canister

**URL:** <https://forum.dfinity.org/t/about-the-upgrade-of-rust-canister/11766>\
**Category:** Rust\
**Created:** [March 29, 2022, 7:24am UTC](https://forum.dfinity.org/t/about-the-upgrade-of-rust-canister/11766 "2022-03-29T07:24:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benxv](https://avatars.discourse-cdn.com/v4/letter/b/3da27b/32.png) [@benxv](https://forum.dfinity.org/u/benxv)\
**Post date:** [March 29, 2022, 7:24am UTC](https://forum.dfinity.org/t/about-the-upgrade-of-rust-canister/11766/1 "2022-03-29T07:24:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AdamS](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/adams/32/5248_2.png) [@AdamS](https://forum.dfinity.org/u/AdamS)\
**Post date:** [March 29, 2022, 2:30pm UTC](https://forum.dfinity.org/t/about-the-upgrade-of-rust-canister/11766/2 "2022-03-29T14:30:43Z")

</div>

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.
