Skip to main content

Checking a canister's chunk store

Advanced

Overview

A canister's chunk store must be empty before a Wasm module can be installed in the canister.

Checking chunk store

You can check if a canister’s chunk store is empty using the following command:

dfx canister call --ic aaaaa-aa stored_chunks '(record { canister_id = principal "PRINCIPAL_ID" })'

Replace PRINCIPAL_ID with a canister ID such as bkyz2-fmaaa-aaaaa-qaaaq-cai.

If the result returns a vec value, the chunk store is not empty.

(
vec {
record {
1_158_164_430 = blob "\96\a2\96\d2\24\f2\85\c6\7b\ee\93\c3\0f\8a\30\91\57\f0\da\a3\5d\c5\b8\7e\41\0b\78\63\0a\09\cf\c7";
};
},
)

If you try to install a Wasm module into a canister that has an existing chunk store, the installation will fail with an error such as:

Failed during wasm installation call: Candid returned an error: input: 4449444c036d016c01cedfa0a804026d7b010003_204b7cb7e28621a6f1110913a33e11455d407f584d3cfe91edf6c12c75b6bd00a2204f7deaf907cea359eda7caa340b204e1558cf451da3fe7582a4cb010a57290d020f52735197797ef2a9e1d2b5d7ed8c13bcd1f41fc65a4731742c12b87f2346bc3
table: type table0 = vec table1
type table1 = record { 1_158_164_430 : table2 }
type table2 = vec nat8
wire_type: record { 1_158_164_430 : table2 }, expect_type: vec nat8

To verify that chunk store is the cause of this error, verify the chunk store has an existing vec value by running the command shown above.

Then, clear the chunk store with the command:

dfx canister call --ic aaaaa-aa clear_chunk_store '(record { canister_id = principal "bkyz2-fmaaa-aaaaa-qaaaq-cai" })'

Then re-run the canister installation command.

Resources

Canister chunk store forum discussion