Skip to content

migrate-db: no checking if the existing postgres database matches the bbolt database being converted #47

Closed

Description

@ZZiigguurraatt

This issue relates to the https://github.com/lightninglabs/lndinit/tree/migrate-db branch, which has not yet been merged with master.

So, here's the scenario I've tested:

  1. Migrate DB to postgres
  2. Restore LND data directory to the state before migration
  3. Try to migrate again to postgres

In this scenario, lndinit migrate-db checks to see if there is a tombstone marker on source DB and when it does not see it, it then checks the postgres database for indication of successful completion. The postgres database sees the successful completion has been marked and then reports !!!Migration of all mandatory db parts completed successfully!!!. In this situation, it did not actually verify anything, it just assumed the old database matches the new one and I don't think it add a tombstone marker to the old database. I think in this scenario, there should be an error message because the old and new DB should both be in agreement on if the conversion happened or not.

Here is another scenario I've tested:

  1. Migrate DB to postgres for node bob
  2. Try to migrate the DB to postgres for node charlie, using the same postgres DB server as bob
  3. I get !!!Migration of all mandatory db parts completed successfully!!!

In this case, I would have expected either of the following

  1. Error out and say you can't use the same postgres server for 2 nodes, or
  2. Create a separate DB inside the same postgres server for the second node.

I can see a situation where one might be running multiple nodes and accidentally use the wrong postgres server when running the conversion tool and I think we need some kind of checking for that. What does LND do if you accidentally point 2 nodes to the same postgres server? Does it have any kind of check?

Activity

  1. ziggie1984 commented on Apr 13, 2025

    @ziggie1984
    Contributor

    Fixed on current working branch. We now make sure the markers are always on both dbs. Moreover we make sure that in case we start a new migration we expect the destination db to be empty. So in the case where we you tried to migrate a new node to the same dns db address, it would now fail and require you to delete the db manually. At this point you should recognize that you are doing something wrong.

  2. self-assigned this
    on Apr 13, 2025
  3. ziggie1984 commented on Apr 17, 2025

    @ziggie1984
    Contributor

    Fixed with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions