Repository navigation
fix: deflake //rs/tests/consensus/subnet_recovery:sr_app_no_upgrade_enable_chain_keys_test_farm_colocate - #11818
Merged
basvandijk merged 3 commits intoOct 12, 2026
Conversation
…nable_chain_keys_test_farm_colocate ic-replay read the hash of the latest state once and treated any error as "the state exists in memory only", falling back to the latest CUP. Since the state manager publishes a checkpoint's manifest from a WaitForManifest request that commit_and_certify enqueues only after the new height is visible, wait_for_state's flush can return before the root hash is published and the fallback reports the CUP's height instead of the checkpoint just created. Poll for the hash instead; only a permanent error means the state is in memory only. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused change correctly addresses the identified race while preserving existing fallback behavior.
0 open findings
What changed in this PR
Fixes replay flakiness by waiting for asynchronously computed checkpoint hashes instead of prematurely falling back to CUP state.
Changes:
- Reuses hash polling for latest state parameters.
- Adds coverage for non-fully-certified states.
| File | Description |
|---|---|
rs/replay/src/player.rs |
Polls transient hash errors and tests the fallback case. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ht 0 Review follow-ups: the no-consensus-pool branch read the highest checkpoint's hash once and would panic on the same transient error; height 0 is never a checkpoint, so polling there would never end. Co-Authored-By: Claude Fable 5.1 <[email protected]>
pierugo-dfinity
approved these changes
Oct 12, 2026
pierugo-dfinity
left a comment
Contributor
There was a problem hiding this comment.
Makes sense thanks!
Review follow-up: the helper now returns None for height 0 itself, so no caller can poll a height the state manager never reports, and the call site no longer needs a guard or a comment about the poll. Co-Authored-By: Claude Fable 5.1 <[email protected]>
pierugo-dfinity
approved these changes
Oct 12, 2026
basvandijk
deleted the
ai/deflake-sr_app_no_upgrade_enable_chain_keys_test_farm_colocate-2026-10-11
branch
October 12, 2026 15:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
//rs/tests/consensus/subnet_recovery:sr_app_no_upgrade_enable_chain_keys_test_farm_colocateflaked once in the week up to 2026-10-11 (2026-10-05 16:19 UTC, on PR #11744's branch). The recovery tool failed inValidateReplayOutput:ic-replayhad replayed 45 batches up to height 245 (the certification height), delivered the extra checkpointing batch 246 and loggedCreated unverified checkpoint @246,Computed root hash ... of state @246andValidated checkpoint @246. Yet itsReplayOutputreported the latest CUP's state,StateParams { height: 200, hash: f3f4ff1b... }, so the validation compared 200 - 1 against 245. In the passing attemptsHeight after replayis the certification height + 1, as intended since #11203.Root cause
Player::get_latest_state_paramsread the hash of the latest state once and treated anyErrfromget_state_hash_atas "the latest state exists in memory only", falling back to the latest CUP. That read can fail transiently for a checkpoint that already exists on disk:commit_and_certifyenqueuesComputeManifestandValidateReplicatedStateAndFinalizeon the tip channel, then has the hash thread insertstates_metadata[height](without a manifest yet) and publish the newlatest_state_height, waits for it, and only then enqueues the follow-upWaitForManifestrequest that publishes the manifest (andResetTipAndMerge).ic-replay'swait_for_statepollslatest_state_heightevery 500 ms and then callsflush_tip_channel. If it observes the new height beforeWaitForManifestis enqueued, itsWaitrequest lands betweenValidateReplicatedStateAndFinalizeandWaitForManifest: the flush returns as soon as the checkpoint is validated, while the root hash is still unpublished, andget_state_hash_atreturnsTransient(HashNotComputedYet).The failing log shows this interleaving. Checkpoint 246 was created and its certification hash computed at 16:19:36.635;
ic-replaysaw height 246 at .664 (one poll later) and its flush returned at .797, right afterValidated checkpoint @246; two furtherwait_for_statecalls at .797 and .798 returned immediately, soWaitForManifestwas still not enqueued;ReplayOutput { height: 200 }was printed at .975, andResetTipAndMerge(enqueued together withWaitForManifest) ran at .969, during the state manager's drop. Whycommit_and_certifyneeded more than 160 ms between publishing the height and enqueueing the follow-ups is inferred, not shown: the hash thread persists the states metadata with an fsync before it answers, and this run's checkpoint creation took 470 ms against 10 ms in the passing attempt.The window exists since async hashing moved the height publication onto the hash thread (#8464, reverted in #10001, re-landed as #10071 on 2026-05-08); the single read in
ic-replaydates from 2022.This is not only a flake: the recovery tool went on to delete every checkpoint but the highest (246) while the state params it would put into the recovery CUP were those of height 200.
ValidateReplayOutputcaught it here, but the corrupted-CUP recoveries skip that step.Fix
Read the hash with the existing
get_state_hashhelper, which retries transient errors every second and returnsNoneonly forStateNotFullyCertified, i.e. a state that really exists in memory only; the fallback to the CUP (or, without a consensus pool, to the highest checkpoint, now read the same way) is unchanged for that case. The helper answers height 0, which is never a checkpoint, withNonewithout polling (an empty state directory would otherwise make the state manager report it as not committed yet forever), soupdate-registry-local-storeon an empty state fails as before instead of waiting. Unit tests pin bothNonecases down.Behaviour changes to be aware of: a
StateRemovederror for the latest state, which cannot happen, now panics instead of silently reporting the CUP; and likeverify_latest_cup, which already used the helper, the poll is unbounded, so a manifest that is never published would makeic-replaylog "Waiting for state hash" every second rather than report a wrong height.Follow-up for the state manager (not in this PR):
flush_tip_channelis documented to finish "all asynchronous checkpointing operations, including ... manifest computation", but a caller on another thread can flush beforecommit_and_certifyhas enqueuedWaitForManifest.ic-replaywas the only such caller; the other callers flush from the committing thread.Not related to #11795: that change only touches the Local backend's bridge, and this run was colocated on Farm.
Testing
cargo check --all-targets --all-features -p ic-replay,cargo fmt,./ci/scripts/rust-lint.sh.bazel build //rs/replay:replay;bazel test //rs/recovery:recovery_test //rs/replay:player_integration_tests //rs/replay:replay_doc_test //rs/replay:replay_test(rerun after each review follow-up).bazel test --runs_per_test=3 --jobs=3 //rs/tests/consensus/subnet_recovery:sr_app_no_upgrade_enable_chain_keys_test_farm_colocate: 3/3 passed on Farm (372 s, 390 s, 380 s), each withHeight after replay= certification height + 1. Passing runs cannot exercise the window, which needs the checkpoint's I/O to be slow; the evidence for the fix is the log analysis above and the unit tests.This PR was created following the steps in
.claude/skills/fix-flaky-tests/SKILL.md.🤖 Generated with Claude Code