[r3.5] cmd/utils: fix allow snapshots reset on upgraded datadirs by restricting table config#22291
Merged
AskAlexSharov merged 1 commit intoJul 8, 2026
Conversation
…config (erigontech#22281) ### Issue Basically, when upgrading Erigon (for example, from v3.4.1 to v3.5.0), we introduce new tables to the schema. The [getChainNameFromChainData](https://github.com/erigontech/erigon/blob/main/cmd/utils/app/reset-datadir.go#L148) helper is called by the `snapshots reset` command to automatically read the chain name from the database. It opens the database with `Accede(true)` and `Readonly(true)` options. But since it was using the default `ChainDB` configuration, it tried to validate the existence of all ~138 tables registered in the schema. Because migrations have not run yet on the upgraded datadir, newly added tables (like `BuilderPendingPayments` or `AccountHistoryKeys`) are physically missing. In Accede mode, MDBX cannot create missing tables, so the database open fails and the reset command crashes with a misleading error about the chain flag not being set. ### Fix To fix this, we need to decouple this simple metadata lookup from the rest of the database schema. The helper only needs to read the genesis canonical hash and the chain config JSON. We have modified the database open call in [getChainNameFromChainData](https://github.com/erigontech/erigon/blob/main/cmd/utils/app/reset-datadir.go#L148) to use `WithTableCfg`. This allows us to pass a minimal table configuration containing only the [HeaderCanonical](https://github.com/erigontech/erigon/blob/main/db/kv/tables.go#L332) and [ConfigTable](https://github.com/erigontech/erigon/blob/main/db/kv/tables.go#L321) tables. Now, it only checks for these two metadata tables and safely ignores any other execution-layer tables. Closes: erigontech#22275
yperbasis
approved these changes
Jul 7, 2026
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.
cherry pick of #22281 in
release/3.5