Skip to content

refactor(state_manager): stop checking the legacy canister log index on checkpoint load - #11013

Open
mraszyk wants to merge 1 commit into
masterfrom
mraszyk/drop-checkpoint-log-invariant
Open

refactor(state_manager): stop checking the legacy canister log index on checkpoint load#11013
mraszyk wants to merge 1 commit into
masterfrom
mraszyk/drop-checkpoint-log-invariant

Conversation

@mraszyk

@mraszyk mraszyk commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

load_canister_state compared log_memory_store.next_idx() against the canister_log.next_idx() decoded from next_canister_log_record_idx, and reported a state_manager_checkpoint_soft_invariant_broken critical error on mismatch.

That check is what makes dropping the legacy canister_log fields from CanisterStateBits a downgrade-breaking change: a replica that no longer writes next_canister_log_record_idx produces checkpoints on which every older replica reports one critical error per canister that has ever logged.

Removing the check here first means that once this version is on mainnet, the legacy fields can be dropped from the checkpoint without tripping the downgrade path.

The log memory store is authoritative for fetch_canister_logs and the delta log index is seeded from log_memory_store.next_idx(), so nothing on the read path depends on the legacy index; after this change it is only written, in tip.rs, for backward compatibility.

…on checkpoint load

`load_canister_state` compared `log_memory_store.next_idx()` against the
`canister_log.next_idx()` decoded from `next_canister_log_record_idx`, and
reported a `state_manager_checkpoint_soft_invariant_broken` critical error on
mismatch.

That check is what makes dropping the legacy `canister_log` fields from
`CanisterStateBits` a downgrade-breaking change: a replica that no longer
writes `next_canister_log_record_idx` produces checkpoints on which every
older replica reports one critical error per canister that has ever logged
(observed as 62 errors in `upgrade_downgrade_nns_subnet_test`).

Removing the check here first means that once this version is on mainnet, the
legacy fields can be dropped from the checkpoint without tripping the
downgrade path.

The log memory store is authoritative for `fetch_canister_logs` and the delta
log index is seeded from `log_memory_store.next_idx()`, so nothing on the read
path depends on the legacy index; after this change it is only written, in
`tip.rs`, for backward compatibility.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR removes a soft-invariant check during checkpoint load that compared the legacy canister_log.next_idx() (decoded from next_canister_log_record_idx) against the authoritative log_memory_store.next_idx(). This helps make it safe to later drop the legacy canister log fields from checkpoints without causing older replicas to emit critical errors when loading new checkpoints.

Changes:

  • Removed the log_memory_store.next_idx() vs canister_log.next_idx() mismatch check in load_canister_state.
  • Eliminated the associated state_manager_checkpoint_soft_invariant_broken critical-error emission for this legacy-index mismatch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mraszyk
mraszyk marked this pull request as ready for review August 3, 2026 15:49
@mraszyk
mraszyk requested a review from a team as a code owner August 3, 2026 15:49
@zeropath-ai

zeropath-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 19bd2ce.

Security Overview
Detected Code Changes
Change Type Relevant files
Bug Fix ► rs/state_manager/src/checkpoint.rs
     Remove invariant check that compared lms_next_idx and log_next_idx and observed mismatch via metrics

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