Skip to content

[sql-58] Add sessions kvdb->SQL migration itest#1211

Open
ViktorT-11 wants to merge 1 commit intolightninglabs:migration-itest-accountsfrom
ViktorT-11:2025-01-session-migration-itest
Open

[sql-58] Add sessions kvdb->SQL migration itest#1211
ViktorT-11 wants to merge 1 commit intolightninglabs:migration-itest-accountsfrom
ViktorT-11:2025-01-session-migration-itest

Conversation

@ViktorT-11
Copy link
Contributor

Based on #1207

Implements part of step 6. of "Phase 3" in #917.

This PR implements itest coverage for the migration of the sessions store.

The benefit of adding migration coverage through itests compared to just unit tests, is that this will test the full migration flow in litd, as it would be executed in production for a user who switches from a bbolt database backend to an SQL database backend.
Additionally, as itests have access to the full litcli, we can also assert parts of the migration through litcli commands, as the end user would experience it.

@ViktorT-11 ViktorT-11 changed the base branch from master to migration-itest-accounts January 27, 2026 12:56
@ViktorT-11 ViktorT-11 added the no-changelog This PR is does not require a release notes entry label Jan 27, 2026
@ViktorT-11 ViktorT-11 mentioned this pull request Jan 27, 2026
46 tasks
@gemini-code-assist
Copy link

Summary of Changes

Hello @ViktorT-11, 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 significantly enhances the robustness of the database migration process by introducing a dedicated integration test for transitioning from KVDB to SQL. It centralizes and standardizes SQL migration management using lnd/sqldb/v2 and a new migration-specific SQLC package, ensuring that critical data stores (accounts, sessions, firewall) are correctly migrated and validated in a production-like environment.

Highlights

  • KVDB to SQL Migration Integration Test: Introduced a comprehensive integration test (itest/litd_migration_test.go) to validate the migration of all key-value database (KVDB) stores (accounts, sessions, and firewall data) to a SQL database backend. This test simulates a full litd migration flow, including data seeding in bbolt, restarting with SQL, and asserting data integrity via direct database access and litcli commands.
  • Migration-Specific SQLC Package: A new db/sqlcmig6 package was added, containing SQLC-generated code specifically tailored for the KVDB to SQL migration. This ensures that migration logic operates against a consistent schema snapshot, preventing issues from future schema changes.
  • Centralized SQL Migration Management: Refactored SQL database migration logic by integrating lnd/sqldb/v2 utilities. This includes new db/migrationstreams packages for managing migration streams and programmatic callbacks, allowing for complex data transformations during the migration process, especially for dev environments.
  • Database Store Refactoring: Updated accounts/store_sql.go, firewalldb/sql_store.go, and session/sql_store.go to leverage the new lnd/sqldb/v2 interfaces for transaction execution and query handling. This standardizes database interactions and improves maintainability across different SQL backends.
  • Go Version Update: The Go toolchain version used across the project, including Dockerfile, Makefile, and various go.mod files, has been updated from 1.24.9 to 1.24.11.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/main.yml
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.

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 comprehensive integration test coverage for the sessions store migration from a bbolt backend to an SQL database. The changes involve significant additions to itest/litd_migration_test.go to set up, assert, and verify session data both before and after the migration, using direct database access and litcli commands. The test suite covers various session configurations, including privacy flags, feature configurations, macaroon recipes, linked accounts (including removed ones), and linked session groups, as well as handling legacy duplicate session IDs. The implementation is thorough and well-structured, ensuring robust validation of the migration process. No critical, high, or medium severity issues were identified.

Implement itest coverage for migrating session data from kvdb to sql.
The itest coverage mimics the unit tests in
sessions/sql_migration_test.go, except for the randomized migration
tests.

This coverage ensures that the full kvdb->SQL migration flow for litd
works as expected for the sessions store.
@lightninglabs-deploy
Copy link

@ViktorT-11, remember to re-request review from reviewers when ready

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

Labels

no-changelog This PR is does not require a release notes entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants