multi: bump pgx/v4 -> pgx/v5, jackc/pgconn -> jackc/pgx/v5/pgconn#10729
multi: bump pgx/v4 -> pgx/v5, jackc/pgconn -> jackc/pgx/v5/pgconn#10729starius wants to merge 6 commits intolightningnetwork:masterfrom
Conversation
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.
Summary of ChangesHello, 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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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.
| pool, err := pgxpool.New(ctx, postgresDatabaseDsn("postgres")) | |
| pool, err := pgxpool.Connect(ctx, postgresDatabaseDsn("postgres")) |
There was a problem hiding this comment.
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.
|
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 --> |
|
@starius, remember to re-request review from reviewers when ready |
Change Description
github.com/jackc/pgx/v4reached EOL on July 1, 2025. We should transition to v5.pgconnis now a part ofpgx/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
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.