build(deps): bump github.com/jackc/pgx/v4 from 4.16.0 to 4.17.1
Bumps [github.com/jackc/pgx/v4](https://github.com/jackc/pgx) from 4.16.0 to 4.17.1. - [Release notes](https://github.com/jackc/pgx/releases) - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v4.16.0...v4.17.1) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
5f29dc312a
commit
b133ff5994
50 changed files with 1503 additions and 253 deletions
74
vendor/github.com/jackc/puddle/pool.go
generated
vendored
74
vendor/github.com/jackc/puddle/pool.go
generated
vendored
|
|
@ -308,32 +308,64 @@ func (p *Pool) Acquire(ctx context.Context) (*Resource, error) {
|
|||
p.destructWG.Add(1)
|
||||
p.cond.L.Unlock()
|
||||
|
||||
value, err := p.constructResourceValue(ctx)
|
||||
p.cond.L.Lock()
|
||||
if err != nil {
|
||||
p.allResources = removeResource(p.allResources, res)
|
||||
p.destructWG.Done()
|
||||
// we create the resource in the background because the constructor might
|
||||
// outlive the context and we want to continue constructing it as long as
|
||||
// necessary but the acquire should be cancelled when the context is cancelled
|
||||
// see: https://github.com/jackc/pgx/issues/1287 and https://github.com/jackc/pgx/issues/1259
|
||||
constructErrCh := make(chan error)
|
||||
go func() {
|
||||
value, err := p.constructResourceValue(ctx)
|
||||
p.cond.L.Lock()
|
||||
if err != nil {
|
||||
p.allResources = removeResource(p.allResources, res)
|
||||
p.destructWG.Done()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if err == ctx.Err() {
|
||||
// we can't use default here in case we get here before the caller is
|
||||
// in the select
|
||||
select {
|
||||
case constructErrCh <- err:
|
||||
case <-ctx.Done():
|
||||
p.canceledAcquireCount += 1
|
||||
}
|
||||
default:
|
||||
p.cond.L.Unlock()
|
||||
p.cond.Signal()
|
||||
return
|
||||
}
|
||||
res.value = value
|
||||
|
||||
p.cond.L.Unlock()
|
||||
p.cond.Signal()
|
||||
return nil, err
|
||||
// assume that we will acquire it
|
||||
res.status = resourceStatusAcquired
|
||||
// we can't use default here in case we get here before the caller is
|
||||
// in the select
|
||||
select {
|
||||
case constructErrCh <- nil:
|
||||
p.emptyAcquireCount += 1
|
||||
p.acquireCount += 1
|
||||
p.acquireDuration += time.Duration(nanotime() - startNano)
|
||||
p.cond.L.Unlock()
|
||||
// we don't call Signal here we didn't change any of the resource pools
|
||||
case <-ctx.Done():
|
||||
p.canceledAcquireCount += 1
|
||||
p.cond.L.Unlock()
|
||||
// we don't call Signal here we didn't change any of the resopurce pools
|
||||
// since we couldn't send the constructed resource to the acquire
|
||||
// function that means the caller has stopped waiting and we should
|
||||
// just put this resource back in the pool
|
||||
p.releaseAcquiredResource(res, res.lastUsedNano)
|
||||
}
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
case err := <-constructErrCh:
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// we don't call signal here because we didn't change the resource pools
|
||||
// at all so waking anything else up won't help
|
||||
return res, nil
|
||||
}
|
||||
|
||||
res.value = value
|
||||
res.status = resourceStatusAcquired
|
||||
p.emptyAcquireCount += 1
|
||||
p.acquireCount += 1
|
||||
p.acquireDuration += time.Duration(nanotime() - startNano)
|
||||
p.cond.L.Unlock()
|
||||
return res, nil
|
||||
}
|
||||
|
||||
if ctx.Done() == nil {
|
||||
|
|
@ -352,8 +384,8 @@ func (p *Pool) Acquire(ctx context.Context) (*Resource, error) {
|
|||
// do anything with it. Another goroutine might be waiting.
|
||||
go func() {
|
||||
<-waitChan
|
||||
p.cond.Signal()
|
||||
p.cond.L.Unlock()
|
||||
p.cond.Signal()
|
||||
}()
|
||||
|
||||
p.cond.L.Lock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue