Commit Graph

67 Commits (ec9840620789766dd065077d314b92cbbaf02ec8)

Author SHA1 Message Date
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 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 3ea2f57d8b Deprecate CheckConn in favor of Ping 2023-06-12 09:39:26 -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 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 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 759e47dba3 Merge branch 'master' into v5-dev 2022-07-12 07:26:00 -05:00
Jack Christensen a059d1099f pgxpool pools always connect lazily
Rename constructor functions now that they don't actually connect.
2022-07-10 14:58:30 -05:00
Jack Christensen 31ec18cc65 Replace Begin and BeginTx methods with functions 2022-07-09 17:25:55 -05:00
Jack Christensen 76946fb5a3 Replace QueryFunc with ForEachScannedRow 2022-07-07 20:29:04 -05:00
Jack Christensen 03da9fcec6 Check conn liveness before using when idle for more than 1 second
Implemented in pgxpool.Pool and database/sql.

https://github.com/jackc/pgx/issues/672
2022-06-25 17:58:53 -05:00
James Hartig a814153aeb pgxpool: health check should avoid going below minConns 2022-06-07 18:38:03 -05:00
Jack Christensen 1f4b34f932 Merge branch 'master' into v5-dev 2022-04-23 11:05:24 -05:00
Jack Christensen 8b483e4223 Use generic / type safe puddle for pgxpool 2022-04-16 09:28:46 -05:00
Jack Christensen bb8c52f7e8 Add doc regarding default pgxpool.Config.MaxConns
refs #1183
2022-04-11 18:49:11 -05:00
Jack Christensen f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Jack Christensen 9c5dfbdfb3 pgconn.CommandTag is now an opaque type
It now makes a copy instead of retaining driver memory. This is in
preparation to reuse the driver read buffer.
2022-02-12 10:26:26 -06:00
Jack Christensen 72cc95e4dd Bump module version to v5 2021-12-11 13:29:03 -06:00
Jack Christensen 0e293b966c Finish import of pgconn 2021-12-04 14:06:57 -06:00
Jack Christensen 058f346079 Start pgxpool background health check after initial connections
Otherwise the health check and the create initial connection(s) may both
create connections. While this generally wouldn't be a real problem it
did cause TestPoolBackgroundChecksMinConns to flicker on CI.
2021-11-20 11:19:10 -06:00
Daniel 8bc6aa6b49 Fix goroutine leak and unclosed connections 2021-10-30 10:25:09 -05:00
Daniel 36708a1cc6 Eager initialize minpoolsize on connect 2021-10-30 10:25:09 -05:00
Dan Gillis bb8d7ffc87 Add comments
Add several comments and correct ConnectConfig
2021-09-25 09:26:59 -05:00
Dan Gillis 8876b3a4ff Add comments 2021-09-11 11:07:31 -05:00
Rulin Tang 5320ad87c8 remove query row connection release 2021-08-23 11:39:45 -05:00
Rulin Tang c9e271df29 add missing pgx pool release for QueryRow 2021-08-23 11:39:45 -05:00
Jack Christensen a49f4bb135 Use errors instead of golang.org/x/xerrors 2021-03-25 09:55:12 -04:00
Jack Christensen 80147fd7cc Use sync.Once to guard pool.Close
This avoids the small possibility of 2 concurrent Close calls still
double closing the channel.
2021-03-19 08:58:56 -05:00
Matt Schultz fe366b2cf3 Prevent panics caused by attempting to close an already closed pgxpool.Pool. 2021-03-19 08:58:56 -05:00
Jack Christensen ac2918b9a3 Add BeginFunc and BeginTxFunc
fixes #821
2021-02-20 18:30:18 -06:00
Jack Christensen 373bb84e9d Add *pgxpool.AcquireFunc
refs #821
2021-02-20 17:16:33 -06:00
davidsbond aa8604b5c2 Add Ping method to pgxpool.Conn
Adds the Ping method to pgxpool.Conn, returning the result of calling Ping on
the underlying pgx.Conn.
2021-01-26 20:46:57 -06:00
Robert Froehlich 210a217818 Add BeforeConnect callback to pgxpool.Config.
This allows for connection settings to be updated without having to create
a new pool. The callback is passed a copy of the pgx.ConnConfig and will
not impact existing live connections.
2021-01-02 15:08:59 -08:00
Jack Christensen e8f959e0e1 Add QueryFunc
refs #821
2020-12-12 09:39:58 -06:00
Jack Christensen 997a16dbc5 Update pgconn for renamed CleanupChan 2020-08-20 22:09:50 -05:00
Jack Christensen 39b096d01e pgxpool waits for connection cleanup to finish before making room in pool
refs #679
2020-08-20 22:04:56 -05:00
georgysavva e29ce9f6d6 Add Config.Copy() in pgx and pgxpool packages. Conn.Config() and Pool.Config() return copy of the original config. 2020-06-02 13:35:05 +03:00
Jack Christensen ac6c49c39d Require access to ConnString via Config
A Config object may be created via ParseConfig and then further
modified. Requiring access to the original ConnString via the Config
helps indicate that the Config is the source of truth as to how the
connection was actually established.
2020-05-16 18:12:04 -05:00