Skip to content

Conversation

@saubyk
Copy link
Collaborator

@saubyk saubyk commented Oct 22, 2025

Change Description

Added a user guide for database migration journey on LND.
This guide would be updated as LND data stores are incrementally migrated to relational database.

@saubyk saubyk self-assigned this Oct 22, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @saubyk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new user guide for LND node operators, outlining a strategic two-stage database migration process. The guide facilitates the transition from the existing bbolt key-value store to more scalable and performant SQLite or PostgreSQL backends. It details how to first migrate to a SQL-based key-value database and then incrementally move specific LND subsystems to a fully relational database structure, aiming to resolve performance bottlenecks and enhance operational efficiency.

Highlights

  • LND Database Migration Guide: Introduces a new comprehensive user guide for LND node operators, detailing a two-stage process to migrate from the legacy bbolt key-value store to modern SQLite or PostgreSQL backends.
  • Two-Stage Migration Process: Explains the migration in two stages: first, from bbolt to a SQL-based kvdb using the lndinit tool, and second, incremental migration of subsystem data from kvdb to native relational tables within LND.
  • Backend Choices and Best Practices: Provides guidance on choosing between SQLite and PostgreSQL, outlines known limitations, and offers best practices for node operators, including timing, backup, and validation steps, along with implementation examples.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@saubyk saubyk added the documentation Documentation changes that do not affect code behaviour label Oct 22, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive user guide for LND's database migration process. The guide is well-structured and provides valuable information for node operators planning to migrate from bbolt to a SQL backend. My review focuses on improving clarity and consistency within the document. I've pointed out a couple of typos, a grammatical issue, and some inconsistencies regarding the availability of the SQLite migration script that could confuse users. I've also suggested a minor rephrasing for better formality. Overall, this is a great addition to the documentation.

@saubyk
Copy link
Collaborator Author

saubyk commented Oct 23, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a comprehensive user guide for the LND database migration process. The guide is well-structured and covers the two-stage migration from bbolt to SQL backends. My review includes a few suggestions to improve clarity, fix a broken link, and address minor formatting issues to enhance the quality of the documentation.

@saubyk saubyk force-pushed the db-migration-guide branch from 82dfbc4 to 0ab4460 Compare October 23, 2025 01:10
@saubyk
Copy link
Collaborator Author

saubyk commented Oct 23, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new user guide for database migration in LND. The guide is well-structured and provides valuable information for node operators. I've added a few comments to improve clarity, consistency, and correctness of the examples provided.

@saubyk saubyk force-pushed the db-migration-guide branch 4 times, most recently from f38a352 to f795e44 Compare October 23, 2025 03:17
Copy link
Collaborator

@ellemouton ellemouton left a comment

Choose a reason for hiding this comment

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

Nice write up 🙏 a few comments

## Known Limitations and Edge Cases

- **Single database engine required**: LND requires a single consistent backend.
You cannot run invoices in relational mode while payments remain in kvdb *unless*
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe use a real example like invoices & graph (since the reference to payments would at this stage be confusing)

| Postgres | Mediocre | No | ✅ |
| SQLite | Good | **Yes (future)** | ✅ |

> 💡 **Recommendation**: Unless you require Postgres for infrastructure reasons, **migrate to SQLite kvdb** as your interim backend.
Copy link
Collaborator

Choose a reason for hiding this comment

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

although, there is no current planned migration between the two.. so it isnt really an interim rn

### Backup and Validation

1. Stop LND.
2. Backup entire `~/.lnd/` directory.
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we actually recommend this? is it not dangerous to have 2 copies of channel.db lying around? cause what if we later startup pointing to the wrong one than then broadcast invalid states?

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

Labels

documentation Documentation changes that do not affect code behaviour no-changelog no-itest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants