sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Always getting "Module hash <hash> is already installed" when trying to upgrade

Open paulyoung opened this issue 2 years ago • 8 comments

I'm attempting to upgrade a custom canister locally by calling dfx canister install --mode upgrade <canister name>

I receive a message saying that the module is already installed despite the gzipped Wasm file being different. I even get this message if I remove the real .wasm.gz file and create an empty one at the expected path using touch, or rm the file.

If I try dfx canister install --mode upgrade --upgrade-unchanged <canister name> I see traces from the upgrade hooks but the canister remains unchanged. My assets canister seems unaffected.

I'm using dfx 0.12.0-beta.1

paulyoung avatar Aug 30 '22 01:08 paulyoung

I’m not sure if this is related to https://github.com/dfinity/sdk/issues/2459, but I upgraded to the beta version to get that fix.

Now I can deploy again but I can no longer upgrade.

paulyoung avatar Aug 31 '22 13:08 paulyoung

I might be able to work around this with dfx canister install --mode upgrade --wasm <canister name>.wasm.gz <canister name>

paulyoung avatar Sep 02 '22 03:09 paulyoung

A quick test doesn't seem to reproduce this issue - it only marks it as duplicate when the gzip hash is the same. Can you describe the process to reproduce this?

adamspofford-dfinity avatar Sep 06 '22 16:09 adamspofford-dfinity

@adamspofford-dfinity I'll try to come up with a minimal way to reproduce this.

paulyoung avatar Sep 09 '22 15:09 paulyoung

I still haven't gotten around to this but I'm still seeing it consistently locally so will try and get to it soon.

paulyoung avatar Sep 24 '22 23:09 paulyoung

Regardless, I think the behaviour of not upgrading just because the hash is the same is dubious.

A user may want to upgrade just to reset wasm memory to initial conditions, or to test the upgrade process, even without the code having changed. If we keep the behaviour, then '-force' option would be useful.

crusso avatar Sep 25 '22 00:09 crusso

There’s already --upgrade-unchanged but as I mentioned in my original comment, it doesn’t help with this issue.

Using the --wasm flag is the only thing that works for me.

paulyoung avatar Sep 25 '22 05:09 paulyoung

I tried creating a minimal example but it doesn't reproduce the issue. When I get some more time I'll try again.

paulyoung avatar Oct 10 '22 21:10 paulyoung