diff --git a/pgxpool/pool.go b/pgxpool/pool.go index cd13be55..236ba000 100644 --- a/pgxpool/pool.go +++ b/pgxpool/pool.go @@ -72,6 +72,12 @@ func (cr *connResource) getPoolRows(c *Conn, r pgx.Rows) *poolRows { // Pool allows for connection reuse. type Pool struct { + // 64 bit fields accessed with atomics must be at beginning of struct to guarantee alignment for certain 32-bit + // architectures. See BUGS section of https://pkg.go.dev/sync/atomic and https://github.com/jackc/pgx/issues/1288. + newConnsCount int64 + lifetimeDestroyCount int64 + idleDestroyCount int64 + p *puddle.Pool[*connResource] config *Config beforeConnect func(context.Context, *pgx.ConnConfig) error @@ -87,10 +93,6 @@ type Pool struct { healthCheckChan chan struct{} - newConnsCount int64 - lifetimeDestroyCount int64 - idleDestroyCount int64 - closeOnce sync.Once closeChan chan struct{} }