-
Notifications
You must be signed in to change notification settings - Fork 5
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(chain): Implement DB migration #132
base: master
Are you sure you want to change the base?
Conversation
9d88714
to
dad9135
Compare
Ok, new approach. Every key is suffixed with a version. (Prefix would also work fine, and might be better for sorting...hmm) I tested this manually by migrating a consensus.db, loading it, and reading from it. When I migrate it again, it's a no-op. When migration is interrupted and resumed, the already-migrated keys are skipped as intended. |
80d719a
to
beda074
Compare
beda074
to
06cb6e2
Compare
06cb6e2
to
f9fae79
Compare
// if the db is empty, initialize it; otherwise, check that the genesis | ||
// block is correct | ||
if dbGenesis, ok := dbs.BestIndex(0); !ok { | ||
if version := dbs.bucket(bVersion).getRaw(dbs.vkey(bVersion)); len(version) != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is currently panicking when trying to migrate a fresh Zen walletd
v0.8.0 database: failed to create chain store: panic during database initialization: bucket already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, steps to reproduce? I don't see that error; here's what I did:
git checkout v0.8.0 && go install ./cmd/walletd
walletd -network zen
- Wait for a few thousand blocks, then Ctrl-C
- In a test function, call
coreutils.OpenBoltChainDB
, thenchain.MigrateDB
, thenchain.NewDBStore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did basically the same, but checked out walletd master with coreutils replaced. Let me double check that I didn’t screw up.
This adds a
MigrateDB
function that converts a DB from one version to the next. Accordingly, the per-block and per-state versions have been removed.I've tested this against
walletd
v0.8.0, though not exhaustively.Currently there is no live feedback during migration. We could add logging or some other form of callback. We also discussed calling
MigrateDB
insideNewDBStore
; I'm open to that, but it would require changing the function signature if we want logs as well, so we'd need to update a lot of callsites.