135 Commits

Author SHA1 Message Date
Christian Kiely
f43091fc80
Support configurable ShouldPing func when acquiring conns 2025-08-06 16:06:03 +10:00
Jonathan Hall
30ff631878 Correction and further clarification of PrepareConn GoDoc comment 2025-07-08 11:45:25 -04:00
Jonathan Hall
f118bb6033 Attempt to acquire a connection MaxConns + 1 times before aborting 2025-06-03 15:09:37 -04:00
Jonathan Hall
48d27a9fff Add PrepareConn hook, which extends BeforeAcquire's behavior to allow canceling the instigating query
- BeforeAcquire now marked as deprecated, and re-implemented in terms of PrepareConn
- PrepareConn now takes precidence over BeforeAcquire if both are provided
- New tests added, so both old and new behavior are tested
- One niggle: AcquireAllIdle does not return an error, so the only recourse
  that seems reasonable when PrepareConn returns an error in that context,
  is to destroy the connection.  This more or less retains the spirit of
  existing functionality, without changing the public API of that method.
  Although maybe an error-returning variant would be a useful addition as
  well.
2025-05-21 11:41:04 -04:00
Yurasov Ilia
3f5509fe98 fix: remove fmt import from the pgxpool 2025-05-18 02:28:24 +03:00
Yurasov Ilia
de806a11e7 fix: return pgconn.ParseConfigError inside ParseConfig functions 2025-05-14 03:50:09 +03:00
Darius Jahandarie
6603ddfbe4
add MinIdleConns 2025-03-15 19:14:26 +09:00
Vamshi Aruru
12b37f3218 Expose puddle.Pool's EmptyAcquireWaitTime in pgxpool's Stats
Addresses: https://github.com/jackc/pgx/issues/2205
2024-12-26 13:46:49 +05:30
Peyton Foley
06a0abb75e
Update pgxpool.ParseConfig documentation
Added default values and example of valid duration string to inline documentation.
2024-11-05 03:09:43 +08:00
Jack Christensen
c457de62c9 Fix doc discrepancies between Tx interface and pgxpool implementation
The error is not wrapped at the moment, but document that it may be.

fixes https://github.com/jackc/pgx/issues/2104
2024-08-07 08:03:41 -05:00
ngavinsir
532bf8f583 adjust test 2024-05-14 20:28:02 -05:00
ngavinsir
169067a364 remove ctx from release tracer 2024-05-14 20:28:02 -05:00
ngavinsir
659525c961 trace release 2024-05-14 20:28:02 -05:00
ngavinsir
4dd1810d8b persist ctx in pgxpool conn 2024-05-14 20:28:02 -05:00
ngavinsir
25914e21f3 add release tracer 2024-05-14 20:28:02 -05:00
ngavinsir
19fcb54564 add pool to trace acquire 2024-05-14 20:28:02 -05:00
ngavinsir
a39632db43 feat: pgx pool acquire tracer 2024-05-14 20:28:02 -05:00
Jack Christensen
a966716860 Replace DSN with keyword/value in comments and documentation
The term DSN is not used in the PostgreSQL documentation. I'm not sure
why it was originally used. Use the correct PostgreSQL terminology.
2024-05-11 14:33:35 -05:00
Alexey Palazhchenko
8fb309c631 Use Go 1.20's link syntax for ParseConfig 2023-07-28 17:51:42 -05:00
James Hartig
e665f74c99 fix TestPoolBackgroundChecksMinConns and NewConnsCount
Previously it was checking TotalConns but that includes ConstructingConns.
Instead it should directly check IdleConns so the next Acquire takes one of
those and doesn't make a 3rd connection. The check against the context was
also wrong which prevented this from timing out after 2 minutes.

This also fixes a bug where NewConnsCount was not correctly counting
connections created by Acquire directly.

Fixes #1690
2023-07-22 08:28:39 -05:00
Jack Christensen
88b49d48f6 Disable TestPoolBackgroundChecksMinConns on Windows
https://github.com/jackc/pgx/issues/1690
2023-07-19 21:20:26 -05:00
Jack Christensen
c513e2e435 Fix: pgxpool: background health check cannot overflow pool
It was previously possible for a connection to be created while the
background health check was running. The health check could create
connection(s) in excess of the maximum pool size in this case.

https://github.com/jackc/pgx/issues/1660
2023-07-15 10:09:53 -05:00
Jack Christensen
05440f9d3f Drastically increase allowed test times for potato CI
The context timeouts for tests are designed to give a better error
message when something hangs rather than the test just timing out.
Unfortunately, the potato CI frequently has some test or another
randomly take a long time. While the increased times are somewhat less
than optimal on a real computer, hopefully this will solve the
flickering CI.
2023-07-11 21:16:08 -05:00
Jack Christensen
34f17a6048 Allow more time for test on slow CI 2023-06-18 08:36:03 -05:00
Jack Christensen
737b5af236 Allow more time for test on slow CI 2023-06-17 19:03:15 -05:00
Jack Christensen
f20070650f Make TestPoolBackgroundChecksMinConns less timing sensitive for CI 2023-06-17 17:34:07 -05:00
Jack Christensen
3ea2f57d8b Deprecate CheckConn in favor of Ping 2023-06-12 09:39:26 -05:00
Jack Christensen
608f39f426 Ensure pgxpool.Pool.QueryRow.Scan releases connection on panic
Otherwise a connection would be leaked and closing the pool would block.

https://github.com/jackc/pgx/issues/1628
2023-06-03 07:39:56 -05:00
Jack Christensen
5f6636d028 Add context timeouts for more pgxpool tests 2023-05-29 11:15:40 -05:00
Jack Christensen
a1a97a7ca8 Add context timeouts for some pgxpool tests 2023-05-29 11:04:52 -05:00
Evan Cordell
cead918e18 run tests that rely on backend PID to run against cockroach
cockroach has supported backend PIDs on connections since 22.1:
https://www.cockroachlabs.com/docs/releases/v22.1.html#v22-1-3-sql-language-changes
2023-05-15 18:06:08 -05:00
Evan Cordell
7f2bb9595f add BeforeClose to pgxpool.Pool 2023-05-15 18:06:08 -05:00
Alexey Palazhchenko
f581584148 Use Go 1.19's lists for proper formatting 2023-01-23 19:54:30 -06:00
Ben Weintraub
29ad306e47 Make MaxConnLifetimeJitter setting actually jitter 2022-12-20 20:18:26 -06:00
Jack Christensen
a05fb80b8a Update docs and changelog for renamed pgxpool.NewWithConfig
fixes https://github.com/jackc/pgx/issues/1306
2022-09-16 18:16:36 -05:00
Jack Christensen
90b69c0ee0 Fix atomic alignment on 32-bit platforms
refs #1288
2022-09-08 20:43:53 -05:00
Jack Christensen
f015ced1bf Use puddle v2.0.0-beta.2 for Acquire in background after cancel 2022-09-03 13:20:19 -05:00
Jack Christensen
ae65a8007b Use higher pgconn.FieldDescription with string Name
Instead of using pgproto3.FieldDescription through pgconn and pgx. This
lets the lowest level pgproto3 still be as memory efficient as possible.

https://github.com/jackc/pgx/pull/1281
2022-08-20 10:04:18 -05:00
Jack Christensen
c842802d65 Failsafe timeout for background pool connections
Do not override existing connect timeout.
2022-08-13 09:49:06 -05:00
Jack Christensen
1819959d07 Merge branch 'master' into v5-dev 2022-08-06 06:41:33 -05:00
Jack Christensen
7ce634d62b Ensure there is a timeout for background pool connections 2022-08-06 06:22:17 -05:00
Jack Christensen
f3e04b28cc Go 1.19 go fmt 2022-08-06 06:20:50 -05:00
Peter Feichtinger
3cb99532f5 pgxpool: Make BeginTx success case clearer 2022-08-04 20:22:57 -05:00
Jack Christensen
0eda0109ca Add Pool.Reset() 2022-07-30 12:22:29 -05:00
Jack Christensen
957671a6ec Use puddle v2 2022-07-30 12:16:16 -05:00
Jack Christensen
033fc6f62a Rename pgxpool.NewConfig to NewWithConfig
https://github.com/jackc/pgx/issues/1264
2022-07-30 09:16:42 -05:00
James Hartig
91c9e841e1 Ignore cancellation in puddle constructor
Fixes #1259
2022-07-30 07:54:16 -05:00
Jack Christensen
b6f5cbd15e Add Conn to Rows interface
https://github.com/jackc/pgx/issues/1191
2022-07-16 17:56:24 -05:00
Jack Christensen
78875bb95a Add tracing support
Replaces existing logging support. Package tracelog provides adapter for
old style logging.

https://github.com/jackc/pgx/issues/1061
2022-07-16 12:27:10 -05:00
Jack Christensen
759e47dba3 Merge branch 'master' into v5-dev 2022-07-12 07:26:00 -05:00