Open
Conversation
Adds ChainStore::rebuild_storage, which drops the chain's schema (if present), upserts the ethereum_networks row to reset head tracking columns, and recreates the schema with empty tables — all in a single transaction. Adds BlockStore::has_namespace and BlockStore::rebuild_chain_storage as the public entry points used by the graphman command.
Adds the rebuild-storage subcommand to graphman chain. Looks up the chain in public.chains, rejects shared-storage chains, prompts for confirmation when storage already exists (--force skips the prompt), then delegates to BlockStore::rebuild_chain_storage.
Covers four scenarios: existing namespace (drop + rebuild), missing namespace, missing ethereum_networks row (full upsert path), and has_namespace returning false after a manual schema drop.
Adds synopsis, description, constraints, and examples for the new chain rebuild-storage subcommand.
Rather than always running DROP SCHEMA IF EXISTS unconditionally, the command layer passes the result of has_namespace as a drop_schema bool down through BlockStore::rebuild_chain_storage into ChainStore::rebuild_storage. When true, the existing Storage::drop_storage is reused; when false, the drop is skipped entirely.
Note that graph-node must be stopped before running the command, making explicit the single-operator assumption baked into the check-then-act flow. Also correct the DROP SCHEMA step description to remove the stale IF EXISTS qualifier.
f68bee0 to
cc90bd2
Compare
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
After manual DB operations or a DB failure it's possible to end up with a chain whose storage schema (e.g.
chain123) has been dropped on the shard while its metadata row inpublic.chainsstill exists.graph-nodecannot recover from this automatically and will fail with:INFO Downloading latest blocks from Ethereum, this may take a few minutes..., provider: arbitrum-one, component: ERRO Trying again after block polling failed: Ingestor error: store error: relation "chain123.blocks" does not exist, provider: arbitrum-one, component: EthereumPollingBlockIngestorCurrently the only way to fix is to manually re-create the schema, tables and
ethereum_networksrecords on the shard.What this PR does:
Adds a new
graphman chain rebuild-storage <CHAIN_NAME>command. It recreates the schema, tables and inserts/updates theethereum_networkstableBehaviour depends on current state:
--forceto skip the prompt.After this, graph-node treats the chain as a freshly added chain.