Stable storage cycle limit


I want to use the stable storage to dump the heap state of my canister and then stream the data off-chain for backup purposes, and so avoid using pre/post upgrade hooks to prevent un-upgradable canister issues.

But I’m hitting this error while trying to restore the previous state from stable memory.

‘The Replica returned an error: code 5, message: “Canister rrkah-fqaaa-aaaaa-aaaaq-cai exceeded the cycles limit for single message execution.”’

This is happening with very few amount of data in stable memory actually, around 30 Mb.

Saving to stable memory works like a charm tho, and for way more data (tried with ~2Gb) than what I’m hitting right now.

Here is a sample code of what I’m trying to achieve, with the restore function unwrapped to spot where it fails

Please tell me if I’m doing something wrong here, I’m starting to get desperate on this one :sweat_smile:

P.S.: Using dfx 0.9.3


After many hours of fun fiddling with bytes, I’ve solved my problem by using my own Serialize process using Bincode.
But the real special trick was to use the upgrade hooks to hack the cycles limitation because they have 40x the cycles limit.

1 Like