-
Notifications
You must be signed in to change notification settings - Fork 18
multi: add migrate-db command #21
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
Conversation
Using this code I was getting an error: So I added a quick patch: getAlby@0ffcae3 And then I was able to do the migration. The last logs were:
It seems everything has migrated succesfully, so I would say that a log line indicating this would also be useful. |
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! |
This is an important PR we need to focus on to allow nodes to finally migrate from kv to native sql. cc @saubyk |
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). |
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.
Still testing, but wanted to note some comments
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 ? |
427fd98
to
67088f2
Compare
Migration now supports sqlite as well. Keep in mind this is still an experimental feature because we need to implement some consistency checks. This PR still needs some work:
Example for the sqlite migration:
make sure the data-dir for the sqlite directory is the same as the boltdb otherwise you need to copy the new files into the other directory when starting lnd. for postgress:
make sure you create a db in postgres before otherwise the opening of the db will fail. Also make sure you choose the correct network, otherwise the bolt.db will not be found in the LND dir. |
67088f2
to
b763270
Compare
db62172
to
9a15a14
Compare
@ziggie1984 Edit: Edit2:
|
Any plans for releasing this feature? It can be released in beta and used at own risk. What is the level of risk loosing money because of broken migration? Is there any way to "dry run" migration and ensure that lnd after the migration is in correct state? |
This feature will be released alongside with LND 19. Currently this feature is not ready for big databases. There is data-consistency checks in the making which will make sure the db migrated correctly. |
The main code change will reside in ziggie1984/migrateboltdb#1 This will make it very easy to move the code to LND in case we decide to do so. |
Missing:
|
After discussing this change we decided to just add a new package to |
OK, so adding my comments as separate issues so we can more easily track. Here's a new one: #47 . |
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.
Awesome work @ziggie1984 and @guggero 🎉
I have one comment that I think is worth considering re: sequence keys.
tACK (also migrated my production node with the last version)
LGTM 🥇
c1b4d8c
to
0293f53
Compare
Justed tested out the latest code, and did a migration to sqlite. The information output is really useful, and it definitely felt like verification was a bit faster. 5 minutes to migrate my smaller test node. 👍 |
I finished growing my database to 32GB this morning
I then fetched the latest code updates, recompiled, and started a new migration test with this tool. The migration tool took 356 minutes when migrating to postgres. My CPU vintage is The resulting postgres DB is only 20GB.
I'm now going to re-try with SQLite. |
I completed the migration of the same database to SQLite on the same machine. The time it took was 324 minutes. Here are the resulting files:
|
42e4513
to
cc522fb
Compare
@ZZiigguurraatt addressed all your issues PTAL |
Migrated my node to SQLITE also successfully:
The others were neglectable. |
I tried starting LND up with
|
Support the migration of bbolt db database to SQL databases (SQLITE/POSTGRES)
This migration tool will allow LND users to migrate
boltdb
databases to sql databases. LND supports two types of SQL databases SQLITE and Postgres.So only the direction
BBolt => SQLITE
orBBOLT => Postgres
is supported.Important:
What is NOT supported (for now):
etcd => SQL (sqlite/postgres)
,bbolt => etcd
nor any variation ofSQLITE => Postgres
etc.So be aware that if you choose to migrate to SQLITE there is currently no way to switch later to Postgres.