Skip to content

feat(db): add --resume flag to migrate-v2#203

Draft
chee-chyuan wants to merge 1 commit into
developfrom
feat/migrate-v2-resume
Draft

feat(db): add --resume flag to migrate-v2#203
chee-chyuan wants to merge 1 commit into
developfrom
feat/migrate-v2-resume

Conversation

@chee-chyuan

Copy link
Copy Markdown
Contributor

Summary

Adds --resume to reth db migrate-v2 so a migration interrupted after the StorageSettings flip can finish without restarting from scratch.

Why

The current migration writes StorageSettings = v2 in phase 3, then clears recomputable MDBX tables in phase 4 and compacts in phase 5. If the process dies between 3 and 5 (e.g. OOM-kill on a large archive node — we hit this on a 9.3 TB BSC archive after the changeset/receipt migration already took ~9 days), re-running falls into the is_v2() → return Ok(()) early-exit and leaves the DB stuck: changesets/receipts are in static files, settings say v2, but MDBX still has the full v1 layout and stage checkpoints are not reset.

--resume jumps straight to phase 4. It verifies StorageSettings is already v2 first, so it can't be used on a fresh DB to skip work that hasn't been done.

Test plan

  • cargo +nightly fmt --all --check
  • cargo check -p reth-cli-commands (verified locally)
  • Manual: run on a half-migrated BSC archive (settings=v2, MDBX still v1)

🤖 Generated with Claude Code

Allows resuming a v1 → v2 migration that was interrupted after the
StorageSettings flip but before MDBX cleanup finished. Without this,
re-running migrate-v2 hits the "already v2" early-exit and leaves the
DB stuck mid-migration (changesets in static files, MDBX still full of
v1 tables).

--resume skips phases 1–3 and runs only clear_recomputable_tables,
compact_mdbx, and the swap. Bails if StorageSettings is not already v2.

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

hashdit-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds a new --resume flag to reth db migrate-v2 and wires it into command parsing by changing Command from a unit struct to a struct with a resume: bool option. It introduces an execute_resume flow that validates StorageSettings is already v2, then performs the remaining destructive/recovery phases (clear recomputable tables, compact MDBX, swap compacted DB) without re-running earlier migration steps. The main execute path now conditionally dispatches to resume mode, addressing interrupted migrations that previously got stuck on the v2 early-exit.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

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.

1 participant