Skip to content

Conversation

@mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Dec 4, 2025

This PR refactors the stable memory representation of events in the migration canister to

  • the history of all events in a map indexed by their sequence numbers;
  • the last event for every pair of source and target canisters represented by its index into the history.

Alternatives considered:

  • a single map BTreeMap<CanisterMigrationArgs, Vec<Event>, Memory> - this representation is inefficient if there are (maliciously) many events for a given pair of source and target canisters;
  • a single map BTreeMap<Event, (), Memory> with events sorted by their pairs of source and target canisters - relying on range queries is fragile and introduces substantial complexity for testing.

@mraszyk mraszyk marked this pull request as ready for review December 4, 2025 17:54
@mraszyk mraszyk requested a review from a team as a code owner December 4, 2025 17:54
HISTORY.with_borrow(|h| {
let event = h
.get(&idx)
.expect("Missing event in history (this is a bug!)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the method returns Option anyway, why not log a critical error and resume? Even if the panic is currently not reachable on critical paths (I have not checked), this may not stay that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by a "critical error"? Is there some monitoring/alerting set up that looks for some string patterns?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. But logging a bug and continuing (with None) may be better than crashing for a state machine where we haven't isolated all individual tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants