Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions op-chain-ops/cmd/celo-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,19 @@ func runDBCheck(opts dbCheckOptions) (err error) {

log.Info("DB Continuity Check Started", "dbPath", opts.dbPath)

// We want to open the db in readonly mode to take advantage of concurrency, but opening in readonly
// mode will fail if the db is missing some files suffixed by ".meta". Our legacy celo db does not have
// ".meta" files, so opening in readonly mode will fail. Opening the db in readwrite mode will create the
// ".meta" files if they don't exist. So, we can open the db in readwrite mode and then close it so
// that the ".meta" files are created. We then reopen the db in readonly mode to run the actual script.
db, err := openDB(opts.dbPath, false)
if err != nil {
return fmt.Errorf("failed to open db in readwrite mode: %w", err)
}
if err = db.Close(); err != nil {
return fmt.Errorf("failed to close db in readwrite mode: %w", err)
}

ancientDB, err := NewChainFreezer(filepath.Join(opts.dbPath, "ancient"), "", true)
Copy link

Choose a reason for hiding this comment

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

With this change can we change how we open the db for the pre and full migrations, which are currently not using readonly.

Copy link
Author

Choose a reason for hiding this comment

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

In theory, but if we ever run those scripts without the continuity script before them for whatever reason they'll have this problem. It would be creating a hard dependency between the scripts. What do you think about that tradeoff?

Copy link

Choose a reason for hiding this comment

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

Oh I was thinking the open/close step came before all flows. Not a big issue.

if err != nil {
return fmt.Errorf("failed to open ancient db: %w", err)
Expand Down