Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tool to migrate stores for fastnode #321

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

forcodedancing
Copy link
Collaborator

@forcodedancing forcodedancing commented Sep 27, 2023

Description

Add tool to migrate the stores, in mutli root store, from IAVL stores to DB stores.

Rationale

For switch a full node to a fast node.

Example

./build/bin/gnfd migrate-store --home ./deployment/localup/.local/dataseed1 

Changes

Notable changes:

  • new command


}
}
if err := batch.WriteSync(); err != nil {
Copy link
Collaborator

@j75689 j75689 Sep 27, 2023

Choose a reason for hiding this comment

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

There are risks with OOM I think, maybe can consider adding a BatchLimit and do WriteSync in the loop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. I had tried to call WriteSync for batches. However, there are some issues, I will figure out it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// WriteSync implements Batch.
func (b *goLevelDBBatch) WriteSync() error {
	return b.write(true)
}

func (b *goLevelDBBatch) write(sync bool) error {
	if b.batch == nil {
		return errBatchClosed
	}
	err := b.db.db.Write(b.batch, &opt.WriteOptions{Sync: sync})
	if err != nil {
		return err
	}
	// Make sure batch cannot be used afterwards. Callers should still call Close(), for errors.
	return b.Close()
}

The batch implementation is wired. After write it will be closed.

At the same time, Batch is rarely used in the project. I will remove the use of batch as well.

@unclezoro unclezoro added this pull request to the merge queue Oct 17, 2023
Merged via the queue into bnb-chain:develop with commit 44e4b58 Oct 17, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants