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

multi: add migrate-db command #21

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

multi: add migrate-db command #21

wants to merge 2 commits into from

Conversation

guggero
Copy link
Member

@guggero guggero commented Jul 4, 2022

This is work in progress and NOT recommended to be used with production/mainnet data!

@kiwiidb
Copy link

kiwiidb commented Jul 14, 2022

Using this code I was getting an error:
Runtime error: db connection set not initialized
I started looking around and found that you were probably missing this: https://github.com/lightningnetwork/lnd/blob/master/lncfg/db.go#L140

So I added a quick patch: getAlby@0ffcae3
(should be a config param probably).

And then I was able to do the migration. The last logs were:

2022-07-14 10:41:42.534 LNDINIT: Opened destination DB
2022-07-14 10:41:42.535 LNDINIT: Checking tombstone marker on source DB
2022-07-14 10:41:42.536 LNDINIT: Checking DB version of source DB
2022-07-14 10:41:42.537 LNDINIT: Checking if migration was already applied to target DB
2022-07-14 10:41:42.540 LNDINIT: Starting the migration to the target backend
2022-07-14 10:41:42.540 LNDINIT: Copying top-level bucket 'waddrmgr'
2022-07-14 10:41:48.981 LNDINIT: Committing bucket 'waddrmgr'
2022-07-14 10:41:48.983 LNDINIT: Copying top-level bucket 'wtxmgr'
2022-07-14 10:41:49.016 LNDINIT: Committing bucket 'wtxmgr'
2022-07-14 10:41:49.017 LNDINIT: Creating 'wallet created' marker
2022-07-14 10:41:49.024 LNDINIT: Committing 'wallet created' marker

It seems everything has migrated succesfully, so I would say that a log line indicating this would also be useful.

@twofaktor
Copy link

twofaktor commented Apr 15, 2024

Hello, what happened with this PR? Have been it abandoned? I think this is very useful to migrate an existing bbolt to postgres and following this guide

Thanks!

@ziggie1984
Copy link

This is an important PR we need to focus on to allow nodes to finally migrate from kv to native sql. cc @saubyk

@Roasbeef
Copy link
Member

Roasbeef commented Oct 2, 2024

sqlite should be added here: https://github.com/lightninglabs/lndinit/pull/21/files#diff-00eb92ba2060dddcdbce2dba1dc551065557b5ebcf98e47e70946e1b50ffd243R453

The top-level bucket structure might also have changed somewhat, so we should update that aspect.

One other thing is we'll need to figure out a way to ensure that all the data has truly been migrated (eg: we don't forget some other top level bucket recently added).

Copy link

@saubyk saubyk left a comment

Choose a reason for hiding this comment

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

Still testing, but wanted to note some comments

Etcd: &etcd.Config{},
Bolt: &Bolt{
DBTimeout: kvdb.DefaultDBTimeout,
Network: "mainnet",
Copy link

Choose a reason for hiding this comment

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

Need support for networks like testnet and regtest as well


### Using postgres as the destination remote database

Prepare a user and database as described in the [Postgres](postgres.md)
Copy link

Choose a reason for hiding this comment

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

data migration (e.g. disable any `systemd` or other scripts that start/stop
`lnd`).

NOTE: If you were using the experimental `etcd` cluster mode that was introduced
Copy link

Choose a reason for hiding this comment

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

Should be a WARNING/CAUTION instead of NOTE

```

If you weren't running a watchtower server, you can remove the line with
`--source.bolt.tower-dir`.
Copy link

Choose a reason for hiding this comment

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

Should end with a section advising user to run the migrated node with the updated db config settings

@ziggie1984 ziggie1984 self-assigned this Nov 5, 2024
@ziggie1984
Copy link

ziggie1984 commented Nov 7, 2024

One other thing is we'll need to figure out a way to ensure that all the data has truly been migrated (eg: we don't forget some other top level bucket recently added).

so you mean having the db files constant here (channeldb, towerdb etc) is not enough but we need to also make sure every new bucket is in the new db ? Hmm not sure I understand this one? Because as long as we iterate through each bucket in the db file, there shouldn't be a problem that we miss a bucket ?

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.

6 participants