Skip to content

lnd+itest: plug in graph SQL migration under test tag & add itest#10071

Merged
guggero merged 4 commits intolightningnetwork:masterfrom
ellemouton:graphSQLMigPlugIn
Jul 15, 2025
Merged

lnd+itest: plug in graph SQL migration under test tag & add itest#10071
guggero merged 4 commits intolightningnetwork:masterfrom
ellemouton:graphSQLMigPlugIn

Conversation

@ellemouton
Copy link
Collaborator

This commit plugs in the graph kvdb-to-sql migration for builds
containing the test_native_sql tag. This will allow us to perform
local tests and write itests for the migration without exposing it to
the production release build.

A basic itests for the migration is also added.

Part of #9795

@ellemouton ellemouton self-assigned this Jul 14, 2025
@ellemouton ellemouton added graph migration itests Issues related to integration tests. no-changelog labels Jul 14, 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.

Summary of Changes

Hello @ellemouton, 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 the framework and an integration test for migrating the graph data from the existing KV database to a new native SQL database. The migration logic is conditionally compiled, ensuring it's only active in builds tagged for native SQL testing, preventing its inclusion in production releases.

Highlights

  • Graph Data Migration Enablement: I've integrated the graph KVDB-to-SQL migration logic into the database builder, allowing lnd to migrate its graph data from the old key-value store to a native SQL database.
  • Test-Specific Activation: This graph migration is specifically enabled only when the test_native_sql build tag is present. This ensures that the migration code and its associated logic are compiled and active solely during testing scenarios, preventing its inclusion in standard production builds.
  • New Integration Test: A comprehensive integration test (testGraphMigration) has been added to validate the graph migration process. This test covers scenarios like initial migration, idempotency (ensuring repeated migrations don't cause issues), and the correct handling of the migration tombstone.
  • Migration Registration: A new migration entry (version 9) for the KV graph migration has been registered within the development migration list, formalizing its place in the database migration sequence for test and development environments.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.

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 plugs in the graph kvdb-to-sql migration for builds containing the test_native_sql tag and adds a basic integration test. I've identified a couple of issues in the new integration test that should be addressed.

@ellemouton
Copy link
Collaborator Author

/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

The pull request introduces a new graph SQL migration under a test tag and adds an integration test. The changes look good overall, with a few suggestions for improvement.

@ellemouton ellemouton requested review from bhandras and guggero July 14, 2025 08:52
Copy link
Collaborator

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Very nice indeed 🎉

{
Name: "kv_graph_migration",
Version: 9,
SchemaVersion: 7,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, not sure how the SchemaVersion currently works. Since the graph migration above has version 8 I kind of would expect this to require version 8 too? cc @bhandras.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So this just means that the custom migration will migrate the schema up to version 7 before we run it, while version is our global version which includes all migrations, schema and in-code as well.

This commit plugs in the graph kvdb-to-sql migration for builds
containing the `test_native_sql` tag. This will allow us to perform
local tests and write itests for the migration without exposing it to
the production release build.
Refactor to make some of the invoice migration helpers re-usable so that
we can use them for the graph migration itests.
This commit adds a basic itest that is run under the `test_native_sql`
flag. It tests that the migration is idempotent and that the node cant
be restarted without the `db.use-native-sql` flag once the graph
migration has been run.
@guggero guggero merged commit 302551a into lightningnetwork:master Jul 15, 2025
69 of 74 checks passed
@ellemouton ellemouton deleted the graphSQLMigPlugIn branch July 15, 2025 08:30
@ellemouton ellemouton restored the graphSQLMigPlugIn branch July 15, 2025 10:36
@ellemouton ellemouton deleted the graphSQLMigPlugIn branch July 15, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graph itests Issues related to integration tests. migration no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants