Skip to content

multi: bump pgx/v4 -> pgx/v5, jackc/pgconn -> jackc/pgx/v5/pgconn#10729

Open
starius wants to merge 6 commits intolightningnetwork:masterfrom
starius:pgx-v4-to-v5
Open

multi: bump pgx/v4 -> pgx/v5, jackc/pgconn -> jackc/pgx/v5/pgconn#10729
starius wants to merge 6 commits intolightningnetwork:masterfrom
starius:pgx-v4-to-v5

Conversation

@starius
Copy link
Copy Markdown
Collaborator

@starius starius commented Apr 11, 2026

Change Description

github.com/jackc/pgx/v4 reached EOL on July 1, 2025. We should transition to v5.

pgconn is now a part of pgx/v5, import paths were updated.

Steps to Test

I ran targeted unit tests. CI should catch regressions if there are any.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

starius added 5 commits April 11, 2026 01:21
In pgx v5, the pgconn package was absorbed into the main pgx module.
Update imports from github.com/jackc/pgconn to
github.com/jackc/pgx/v5/pgconn and remove the now-unnecessary
standalone pgconn dependency from go.mod.
In pgx v5, the pgconn package was absorbed into the main pgx module.
Update imports from github.com/jackc/pgconn to
github.com/jackc/pgx/v5/pgconn and remove the now-unnecessary
standalone pgconn dependency from go.mod.
Update the SQL driver registration import from pgx/v4/stdlib to
pgx/v5/stdlib, completing the migration of the kvdb module away from
the deprecated pgx v4.
Add a local replace directive for kvdb so the main module can reference
the local kvdb changes (pgx/v5 migration) before a new kvdb version is
released.
Update the main module's pgxpool usage from pgx/v4 to pgx/v5:
- Change import from pgx/v4/pgxpool to pgx/v5/pgxpool
- Update pgxpool.Connect to pgxpool.New (v5 API change)
- Remove pgx/v4 and its transitive dependencies from go.mod

Note: pgxpool.New is lazy, but this is done in tests only and the very next
line is pool.Exec, so if there is a connection error, it will be caught there.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 performs a necessary migration from pgx/v4 to pgx/v5 across the repository to address the end-of-life status of the older version. The changes involve updating dependency definitions in go.mod files, adjusting import paths for pgconn, and updating connection pool initialization code to align with the v5 API.

Highlights

  • Dependency Upgrade: Upgraded from pgx/v4 to pgx/v5, as pgx/v4 has reached end-of-life.
  • Import Path Updates: Updated import paths for pgconn, which is now integrated into pgx/v5.

🧠 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.

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.

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.

@github-actions github-actions Bot added the severity-high Requires knowledgeable engineer review label Apr 11, 2026
Copy link
Copy Markdown

@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 updates the PostgreSQL driver from pgx/v4 to pgx/v5 across the repository, including updates to the kvdb and sqldb packages and the integration test harness. A regression was identified in lntest/node/harness_node.go where the use of pgxpool.New instead of pgxpool.Connect removes the implicit connectivity check (Ping) that the existing error handling relies on. It is recommended to use pgxpool.Connect to ensure the database is reachable before proceeding, maintaining the behavior from the previous driver version.

// executePgQuery executes a SQL statement in a postgres db.
func executePgQuery(ctx context.Context, query string) error {
pool, err := pgxpool.Connect(ctx, postgresDatabaseDsn("postgres"))
pool, err := pgxpool.New(ctx, postgresDatabaseDsn("postgres"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In pgx/v5, pgxpool.New only initializes the pool and parses the configuration; it does not establish a connection or verify connectivity. Since the subsequent error check expects a connection failure ("unable to connect to database"), pgxpool.Connect should be used instead, as it performs a Ping internally to ensure the database is reachable, maintaining the behavior from pgx/v4.

Suggested change
pool, err := pgxpool.New(ctx, postgresDatabaseDsn("postgres"))
pool, err := pgxpool.Connect(ctx, postgresDatabaseDsn("postgres"))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There is no pgxpool.Connect in pgx/v5, that is why we switched.
In the commit message there is a note about this:

pgxpool.New is lazy, but this is done in tests only and the very next line is pool.Exec, so if there is a connection error, it will be caught there.

@github-actions
Copy link
Copy Markdown

PR Severity HIGH. sqldb files are HIGH tier. Dependency version bump with minor one-line edits to SQL error handling files. 9 qualifying files, 34 qualifying lines. pr-severity-bot marker: <!-- pr-severity-bot -->

Copy link
Copy Markdown
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM

@saubyk saubyk added this to the v0.22.0 milestone May 1, 2026
@saubyk saubyk added this to lnd v0.22 May 1, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in lnd v0.22 May 1, 2026
@saubyk saubyk moved this from Backlog to In review in lnd v0.22 May 1, 2026
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@starius, 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 severity-high Requires knowledgeable engineer review

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants