diff --git a/backend/canisters/online_users/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/online_users/impl/src/lifecycle/post_upgrade.rs index 7ba1c36fda..a434762fb0 100644 --- a/backend/canisters/online_users/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/online_users/impl/src/lifecycle/post_upgrade.rs @@ -1,6 +1,6 @@ use crate::lifecycle::{init_env, init_state}; use crate::memory::get_upgrades_memory; -use crate::Data; +use crate::{mutate_state, Data}; use canister_logger::LogEntry; use canister_tracing_macros::trace; use ic_cdk::post_upgrade; @@ -24,4 +24,7 @@ fn post_upgrade(args: Args) { init_state(env, data, args.wasm_version); info!(version = %args.wasm_version, "Post-upgrade complete"); + + // TODO remove this after upgrade + mutate_state(|state| state.data.principal_to_user_id_map.clear()); } diff --git a/backend/canisters/online_users/impl/src/model/principal_to_user_id_map.rs b/backend/canisters/online_users/impl/src/model/principal_to_user_id_map.rs index 93ed0cdfb8..d4fb12df1e 100644 --- a/backend/canisters/online_users/impl/src/model/principal_to_user_id_map.rs +++ b/backend/canisters/online_users/impl/src/model/principal_to_user_id_map.rs @@ -18,6 +18,10 @@ impl PrincipalToUserIdMap { pub fn get(&self, principal: &Principal) -> Option { self.map.get(principal).map(|u| u.into()) } + + pub fn clear(&mut self) { + self.map.clear_new() + } } fn init_map() -> StableBTreeMap {