Skip to content

WIRE-420: explain recovery after interrupted chain initialization - #681

Merged
huangminghuang merged 4 commits into
masterfrom
fix/wire-420-interrupted-chain-initialization
Oct 21, 2026
Merged

huangminghuang merged 4 commits into
masterfrom
fix/wire-420-interrupted-chain-initialization

Conversation

@huangminghuang

@huangminghuang huangminghuang commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Report a missing state database version header after interrupted initialization with a one-time --delete-all-blocks recovery instruction.
  • Report an empty active blocks.log with its path and the same recovery instruction, while retaining archived-log priority and rejection of malformed logs.

Why

WIRE-420: a failed first launch can leave a headerless state database and a zero-byte block log. The previous errors suggested an incompatible snapshot or an unreadable file without explaining the recovery. Writing the database header during index registration would also let a partially loaded snapshot appear initialized on a later launch. Keep header creation at genesis or snapshot startup and fail with actionable diagnostics when initialization stopped earlier.

--delete-all-blocks clears the state database and block log while leaving finalizers/ intact.

Integration with current master

  • Merged master at 6ded364fde2a86ddd2cb3d2d3000dd68e8e0e2a5 in merge commit 505743961f94b51252e8d3d50feb08e970bee05b.
  • Resolved the overlap in restart_chain_tests.cpp by retaining both WIRE-420 diagnostic cases and the WIRE-389 transaction-dedup persistence cases. The PR's net diff remains the four intended controller, block-log, and test files.

Validation

  • On the merged head, rebuilt unit_test with Clang 18 Release and ran the restart_chain_tests and block_log_extraction_tests CTest suites under --sys-vm-jit: both passed.
  • Before the base merge, focused restart_chain_tests and block_log_extraction_tests under --sys-vm-jit passed (12 cases, 59 assertions), including both exact recovery messages. Focused chain_plugin_tests passed (5 cases, 123 assertions).

Change-Id: Id1d8f43d7ec9ac42bcbc8a544d71e5c94dc6fd27

@heifner heifner 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.

I'd rather not make interrupted initialization restartable. A first launch that fails before chain startup leaves nothing worth keeping: an empty state database and a 0-byte blocks.log. Rerunning once with --delete-all-blocks is the recovery. Creating the header early also adds a new state: a snapshot load that aborts partway now leaves a header at revision 0, and a later genesis start initializes over the partial rows instead of refusing.

What needs fixing is the error messages. After a first launch fails in a later plugin's init:

  • The relaunch fails with "state database version pre-dates versioning, please restore from a compatible snapshot or replay!", which points the wrong way.
  • Removing only state/ (which the --snapshot error tells you to do) then fails on the empty blocks.log: "cfile: …/blocks.log unable to read 4 bytes; only read 0, eof: true".

Could you replace the header and block-log changes with two clear errors?

  1. Missing header (validate_db_version): "State database has no version header: the launch that created it did not complete startup. Rerun once with --delete-all-blocks."
  2. Empty active blocks.log (extract_block_log_preamble): a block_log_exception with "<path> is empty: the launch that created it did not complete startup. Rerun once with --delete-all-blocks."

--delete-all-blocks keeps finalizers/, and the --snapshot-endpoint error already gives the same advice. A test for each message is enough.

@huangminghuang
huangminghuang marked this pull request as draft October 20, 2026 20:17
Change-Id: I947ddc4ef7d132c901082ac5480466cf0438b994
Change-Id: I809d4aef0c6b14394057e5f25c3d90ff1676badf
@huangminghuang huangminghuang changed the title WIRE-420: recover from interrupted chain initialization WIRE-420: explain recovery after interrupted chain initialization Oct 20, 2026
heifner
heifner previously approved these changes Oct 21, 2026
Change-Id: I3d4b0e9230e79b41a8754d594c5120189aedd54d
@huangminghuang
huangminghuang marked this pull request as ready for review October 21, 2026 20:37
@huangminghuang
huangminghuang merged commit 945e40a into master Oct 21, 2026
13 checks passed
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