Skip to content

fix: migration crash on min-GC RPC nodes#15975

Merged
Trisfald merged 1 commit into
near:2.13-releasefrom
Trisfald:fix/migration-48-49-gc-epoch-sync-proof
Jun 25, 2026
Merged

fix: migration crash on min-GC RPC nodes#15975
Trisfald merged 1 commit into
near:2.13-releasefrom
Trisfald:fix/migration-48-49-gc-epoch-sync-proof

Conversation

@Trisfald

Copy link
Copy Markdown
Contributor

Upgrading to 2.13 (DB 48->49) crashed at startup on nodes with gc_num_epochs_to_keep = 3 with DB Not Found Error: epoch block: <hash>.

Cause: the migration regenerated the epoch sync proof via find_target_epoch_to_produce_proof_for, which anchors at the final head and reads BlockInfo ~4 epochs back, which gc=3 has already collected.

Fix: build the proof anchored at the current epoch (target head-2), the same way continuous epoch sync does at a boundary. If the node restarted mid-epoch, where even head-2's inputs are collected, fall back to the freshest fully retained epoch (head-1).

@Trisfald Trisfald changed the title fix: 48->49 migration crash on min-GC RPC nodes fix: migration crash on min-GC RPC nodes Jun 25, 2026
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (2.13-release@2fa36db). Learn more about missing BASE report.

Files with missing lines Patch % Lines
nearcore/src/migrations.rs 75.00% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             2.13-release   #15975   +/-   ##
===============================================
  Coverage                ?   69.69%           
===============================================
  Files                   ?      946           
  Lines                   ?   204333           
  Branches                ?   204333           
===============================================
  Hits                    ?   142414           
  Misses                  ?    57161           
  Partials                ?     4758           
Flag Coverage Δ
pytests-nightly 1.10% <0.00%> (?)
unittests 69.45% <75.00%> (?)
unittests-nightly 69.40% <75.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Trisfald Trisfald marked this pull request as ready for review June 25, 2026 11:52
@Trisfald Trisfald requested a review from a team as a code owner June 25, 2026 11:52
@Trisfald Trisfald merged commit b129680 into near:2.13-release Jun 25, 2026
29 of 33 checks passed
jancionear pushed a commit to jancionear/nearcore that referenced this pull request Jun 25, 2026
**Same as near#15975**

Upgrading to 2.13 (DB 48->49) crashed at startup on nodes with
`gc_num_epochs_to_keep = 3` with `DB Not Found Error: epoch block:
<hash>`.

Cause: the migration regenerated the epoch sync proof via
`find_target_epoch_to_produce_proof_for`, which anchors at the final
head and reads BlockInfo ~4 epochs back, which gc=3 has already
collected.

Fix: build the proof anchored at the current epoch (target head-2), the
same way continuous epoch sync does at a boundary. If the node restarted
mid-epoch, where even head-2's inputs are collected, fall back to the
freshest fully retained epoch (head-1).
@github-actions github-actions Bot mentioned this pull request Jun 26, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants