Skip to content

Commit

Permalink
Fix atomic alignment on 32-bit platforms
Browse files Browse the repository at this point in the history
refs #1288
  • Loading branch information
jackc committed Aug 27, 2022
1 parent 1d748d9 commit bce26b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pgxpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{}
}
Expand Down

0 comments on commit bce26b8

Please sign in to comment.