Skip to content

Commit

Permalink
Merge branch 'abk/run-758-delete-new-pagemap-file' into 'master'
Browse files Browse the repository at this point in the history
RUN-758: Remove Wasm chunk store file

In case we roll out Wasm chunk store changes and then roll back, this
logic will delete any left over pagemap files. 

See merge request dfinity-lab/public/ic!14668
  • Loading branch information
adambratschikaye committed Sep 11, 2023
2 parents c3b0d69 + 76e3dd2 commit 89916d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rs/state_layout/src/state_layout.rs
Expand Up @@ -226,7 +226,8 @@ struct CheckpointRefData {
/// │ │ ├── queues.pbuf
/// │ │ ├── software.wasm
/// │ │ ├── stable_memory.bin
/// │ │ └── vmemory_0.bin
/// │ │ ├── vmemory_0.bin
/// │ │ └── wasm_chunk_store.bin
/// │ ├── ingress_history.pbuf
/// │ ├── split_from.pbuf
/// │ ├── subnet_queues.pbuf
Expand Down Expand Up @@ -1363,6 +1364,10 @@ impl<Permissions: AccessPolicy> CanisterLayout<Permissions> {
pub fn stable_memory_blob(&self) -> PathBuf {
self.canister_root.join("stable_memory.bin")
}

pub fn wasm_chunk_store(&self) -> PathBuf {
self.canister_root.join("wasm_chunk_store.bin")
}
}

fn open_for_write(path: &Path) -> Result<std::fs::File, LayoutError> {
Expand Down
12 changes: 12 additions & 0 deletions rs/state_manager/src/tip.rs
Expand Up @@ -482,6 +482,18 @@ fn serialize_canister_to_tip(
None
}
};

// Remove the wasm_chunk_store file in case we have rolled back after creating it.
if canister_layout.wasm_chunk_store().exists() {
std::fs::remove_file(canister_layout.wasm_chunk_store()).map_err(|io_err| {
CheckpointError::IoError {
path: canister_layout.wasm_chunk_store().to_path_buf(),
message: "failed to delete existing Wasm chunk store file".to_string(),
io_err: io_err.to_string(),
}
})?;
}

// Priority credit must be zero at this point
assert_eq!(canister_state.scheduler_state.priority_credit.get(), 0);
canister_layout.canister().serialize(
Expand Down

0 comments on commit 89916d9

Please sign in to comment.