Skip to content

fix: canister log migration#10241

Merged
mraszyk merged 29 commits into
masterfrom
mraszyk/migrate-logs-on-checkpoint-load
May 19, 2026
Merged

fix: canister log migration#10241
mraszyk merged 29 commits into
masterfrom
mraszyk/migrate-logs-on-checkpoint-load

Conversation

@mraszyk
Copy link
Copy Markdown
Contributor

@mraszyk mraszyk commented May 18, 2026

This PR fixes canister log (data) migration:

  • a new Boolean value migrated in canister.pbuf (inside log_memory_store in SystemState) tells if logs have been migrated from the (legacy) field canister_log in SystemState to the new field log_memory_store in SystemState:
    • default to false for existing canisters (transparently by protobuf since the field is currently missing);
    • set to the feature flag for new canisters (so that new canisters are not labeled as not migrated once the feature is enabled);
  • fetch_canister_logs uses the new log_memory_store if the feature flag is true and the store is migrated;
  • data migration: at the very beginning of SchedulerImpl::execute_round, for every canister
    • if the feature flag is true and the canister’s log memory store is not migrated => migrate (resize store to 4KiB – which is the maximum size of the legacy canister_log in SystemState –, migrate records, set migrated to true);
    • if the feature flag is false and the canister’s log memory store is migrated (i.e., after a downgrade) => “undo” migration (clear the log memory store by resizing down to 0 and reset migrated to false).

The log_memory_store_feature flag is used:

  • to trigger data migration and rollback in SchedulerImpl::execute_round;
  • to initialize the migrated field for newly created canisters;
  • to select between the legacy canister_log and new log_memory_store when reading logs via fetch_canister_logs (this way, flipping the flag immediately falls back to the legacy canister_log).

The migrated field is used:

  • to ensure that data migration is one-off;
  • to determine the byte capacity for canister logs during execution;
  • to determine if new canister logs should be appended to the new log_memory_store;
  • to determine if canister logs should be read from the new log_memory_store;
  • to determine if the new log_memory_store can be resized via update_settings;
  • to determine if metrics should be recorded for the new log_memory_store.

@mraszyk mraszyk added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label May 18, 2026
@github-actions github-actions Bot added the fix label May 18, 2026
Comment thread rs/state_manager/src/tip.rs
@mraszyk mraszyk marked this pull request as ready for review May 19, 2026 11:34
@mraszyk mraszyk requested review from a team as code owners May 19, 2026 11:34
Copy link
Copy Markdown
Collaborator

@basvandijk basvandijk left a comment

Choose a reason for hiding this comment

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

rs/tests changes LGTM.

Comment thread rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs Outdated
Comment thread rs/execution_environment/src/canister_logs.rs Outdated
Comment thread rs/execution_environment/tests/canister_logging.rs Outdated
@mraszyk mraszyk added this pull request to the merge queue May 19, 2026
Merged via the queue into master with commit 752fff4 May 19, 2026
37 checks passed
@mraszyk mraszyk deleted the mraszyk/migrate-logs-on-checkpoint-load branch May 19, 2026 14:36
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.

4 participants