2
0

Fix atomic alignment on 32-bit platforms

refs #1288
This commit is contained in:
Jack Christensen
2022-08-27 09:23:17 -05:00
parent 1d748d9bbf
commit bce26b85d1
+6 -4
View File
@@ -82,6 +82,12 @@ func (detachedCtx) Err() error { return nil }
// 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
config *Config
beforeConnect func(context.Context, *pgx.ConnConfig) error
@@ -96,10 +102,6 @@ type Pool struct {
healthCheckPeriod time.Duration
healthCheckChan chan struct{}
newConnsCount int64
lifetimeDestroyCount int64
idleDestroyCount int64
closeOnce sync.Once
closeChan chan struct{}
}