Skip to content

Commit

Permalink
Remove code to migrate community events to stable memory (#6769)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Nov 8, 2024
1 parent 7ac6467 commit 9af3d54
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 72 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Reduce size of metrics in memory ([#6765](https://github.com/open-chat-labs/open-chat/pull/6765))

### Removed

- Remove code to migrate events to stable memory now that it is complete ([#6769](https://github.com/open-chat-labs/open-chat/pull/6769))

## [[2.0.1433](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1433-community)] - 2024-11-07

### Changed
Expand Down
1 change: 0 additions & 1 deletion backend/canisters/community/impl/src/jobs/import_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ pub(crate) fn finalize_group_import(group_id: ChatId) {
chat,
date_imported: None, // This is only set once everything is complete
});
state.data.stable_memory_event_migration_complete = false;

state.data.timer_jobs.enqueue_job(
TimerJob::ProcessGroupImportChannelMembers(ProcessGroupImportChannelMembersJob {
Expand Down
4 changes: 0 additions & 4 deletions backend/canisters/community/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ impl RuntimeState {
instruction_counts: self.data.instruction_counts_log.iter().collect(),
event_store_client_info: self.data.event_store_client.info(),
timer_jobs: self.data.timer_jobs.len() as u32,
stable_memory_event_migration_complete: self.data.stable_memory_event_migration_complete,
canister_ids: CanisterIds {
user_index: self.data.user_index_canister_id,
group_index: self.data.group_index_canister_id,
Expand Down Expand Up @@ -367,7 +366,6 @@ struct Data {
expiring_member_actions: ExpiringMemberActions,
user_cache: UserCache,
user_event_sync_queue: GroupedTimerJobQueue<UserEventBatch>,
stable_memory_event_migration_complete: bool,
stable_memory_keys_to_garbage_collect: Vec<KeyPrefix>,
}

Expand Down Expand Up @@ -470,7 +468,6 @@ impl Data {
expiring_member_actions: ExpiringMemberActions::default(),
user_cache: UserCache::default(),
user_event_sync_queue: GroupedTimerJobQueue::new(5, true),
stable_memory_event_migration_complete: true,
stable_memory_keys_to_garbage_collect: Vec::new(),
}
}
Expand Down Expand Up @@ -715,7 +712,6 @@ pub struct Metrics {
pub instruction_counts: Vec<InstructionCountEntry>,
pub event_store_client_info: EventStoreClientInfo,
pub timer_jobs: u32,
pub stable_memory_event_migration_complete: bool,
pub canister_ids: CanisterIds,
}

Expand Down
13 changes: 1 addition & 12 deletions backend/canisters/community/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,9 @@ fn post_upgrade(args: Args) {
let memory = get_upgrades_memory();
let reader = get_reader(&memory);

let (mut data, errors, logs, traces): (Data, Vec<LogEntry>, Vec<LogEntry>, Vec<LogEntry>) =
let (data, errors, logs, traces): (Data, Vec<LogEntry>, Vec<LogEntry>, Vec<LogEntry>) =
msgpack::deserialize(reader).unwrap();

// Only proceed with removing events from the heap if the stable memory migration is complete
assert!(data.stable_memory_event_migration_complete);

// Set the migration flag to false if threads need to be updated, but this can be done purely
// in stable memory so no need to abort the upgrade
for channel in data.channels.iter_mut() {
if channel.chat.events.thread_messages_to_update_in_stable_memory_len() > 0 {
data.stable_memory_event_migration_complete = false;
}
}

canister_logger::init_with_logs(data.test_mode, errors, logs, traces);

let env = init_env(data.rng_seed);
Expand Down
13 changes: 1 addition & 12 deletions backend/canisters/community/impl/src/regular_jobs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::updates::c2c_migrate_events_to_stable_memory::migrate_events_to_stable_memory_impl;
use crate::Data;
use utils::env::Environment;
use utils::regular_jobs::{RegularJob, RegularJobs};
Expand All @@ -8,14 +7,8 @@ pub(crate) fn build() -> RegularJobs<Data> {
let check_cycles_balance = RegularJob::new("Check cycles balance", check_cycles_balance, 5 * MINUTE_IN_MS);
let retry_deleting_files = RegularJob::new("Retry deleting files", retry_deleting_files, MINUTE_IN_MS);
let build_chat_metrics = RegularJob::new("Build chat metrics", build_chat_metrics, 30 * MINUTE_IN_MS);
let migrate_chat_events_to_stable_memory = RegularJob::new("Migrate chat events", migrate_chat_events_to_stable_memory, 0);

RegularJobs::new(vec![
check_cycles_balance,
retry_deleting_files,
build_chat_metrics,
migrate_chat_events_to_stable_memory,
])
RegularJobs::new(vec![check_cycles_balance, retry_deleting_files, build_chat_metrics])
}

fn check_cycles_balance(_: &dyn Environment, data: &mut Data) {
Expand All @@ -29,7 +22,3 @@ fn retry_deleting_files(_: &dyn Environment, _: &mut Data) {
fn build_chat_metrics(env: &dyn Environment, data: &mut Data) {
data.build_chat_metrics(env.now());
}

fn migrate_chat_events_to_stable_memory(_: &dyn Environment, data: &mut Data) {
migrate_events_to_stable_memory_impl(data, true);
}

This file was deleted.

1 change: 0 additions & 1 deletion backend/canisters/community/impl/src/updates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod c2c_invite_users_to_channel;
pub mod c2c_join_channel;
pub mod c2c_join_community;
pub mod c2c_leave_community;
pub mod c2c_migrate_events_to_stable_memory;
pub mod c2c_notify_p2p_swap_status_change;
pub mod c2c_set_user_suspended;
pub mod c2c_tip_message;
Expand Down

0 comments on commit 9af3d54

Please sign in to comment.