Skip to content

Conversation

@canepat
Copy link
Member

@canepat canepat commented Aug 21, 2025

After adding integration run_migrations step within RPC Integration Tests, some runs started to fail intermittently on Gnosis and Polygon with error "database is not initialized":

https://github.com/erigontech/erigon/actions/runs/17097843879/job/48486419048
https://github.com/erigontech/erigon/actions/runs/17097843833/job/48486419046
https://github.com/erigontech/erigon/actions/runs/17099664503/job/48492523550

It turns out the unpredictable order of range iteration over dbPaths map can lead any database different from chaindata to be opened as first, which triggers the openSnapshotOnce function to be executed on a database with empty Config table, hence the error.

This guarantees that chaindata is always migrated as first.

// (see openSnapshotOnce in allSnapshots below).
migrateDB(kv.ChainDB, chaindata)

dbPaths := map[kv.Label]string{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if chaindata must be first - then just don't use map use array.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, this can be simplified. neither a map nor an array is needed: I'll just call migrateDB instead of filling a useless data structure

@canepat canepat requested a review from AskAlexSharov August 22, 2025 10:08
@AskAlexSharov AskAlexSharov merged commit 8f7571c into main Aug 22, 2025
15 checks passed
@AskAlexSharov AskAlexSharov deleted the canepat/run_migrations_fix_database_not_initialized branch August 22, 2025 13:22
canepat added a commit that referenced this pull request Sep 1, 2025
canepat added a commit that referenced this pull request Sep 1, 2025
AskAlexSharov pushed a commit that referenced this pull request Sep 2, 2025
…16935)

Cherry-pick #16678
Cherry-pick #16711
Cherry-pick #16762

---------

Co-authored-by: Shoham Chakraborty <[email protected]>
yperbasis pushed a commit that referenced this pull request Sep 12, 2025
…16936)

Cherry-pick #16678
Cherry-pick #16711
Cherry-pick #16762

---------

Co-authored-by: Shoham Chakraborty <[email protected]>
NazariiDenha pushed a commit that referenced this pull request Oct 24, 2025
After adding `integration run_migrations` step within RPC Integration
Tests, some runs started to fail intermittently on Gnosis and Polygon
with error "database is not initialized":


https://github.com/erigontech/erigon/actions/runs/17097843879/job/48486419048

https://github.com/erigontech/erigon/actions/runs/17097843833/job/48486419046

https://github.com/erigontech/erigon/actions/runs/17099664503/job/48492523550

It turns out the unpredictable order of range iteration over `dbPaths`
map can lead any database different from `chaindata` to be opened as
first, which triggers the `openSnapshotOnce` function to be executed on
a database with empty `Config` table, hence the error.

This guarantees that `chaindata` is always migrated as first.
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.

4 participants