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
16
vendor/github.com/jackc/puddle/.travis.yml
generated
vendored
16
vendor/github.com/jackc/puddle/.travis.yml
generated
vendored
|
|
@ -1,16 +0,0 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.x
|
||||
- tip
|
||||
|
||||
env:
|
||||
global:
|
||||
- STRESS_TEST_DURATION=15s
|
||||
|
||||
script:
|
||||
- go test -v -race
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip
|
||||
4
vendor/github.com/jackc/puddle/CHANGELOG.md
generated
vendored
4
vendor/github.com/jackc/puddle/CHANGELOG.md
generated
vendored
|
|
@ -1,3 +1,7 @@
|
|||
# 1.3.0 (August 27, 2022)
|
||||
|
||||
* Acquire creates resources in background to allow creation to continue after Acquire is canceled (James Hartig)
|
||||
|
||||
# 1.2.1 (December 2, 2021)
|
||||
|
||||
* TryAcquire now does not block when background constructing resource
|
||||
|
|
|
|||
10
vendor/github.com/jackc/puddle/README.md
generated
vendored
10
vendor/github.com/jackc/puddle/README.md
generated
vendored
|
|
@ -1,5 +1,5 @@
|
|||
[](https://godoc.org/github.com/jackc/puddle)
|
||||
[](https://travis-ci.org/jackc/puddle)
|
||||

|
||||
|
||||
# Puddle
|
||||
|
||||
|
|
@ -49,6 +49,14 @@ res.Release()
|
|||
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
Puddle v1 is complete. No changes are planned.
|
||||
|
||||
* Bug reports and fixes are welcome.
|
||||
* New features will not be accepted if they can be feasibly implemented in a wrapper.
|
||||
* Performance optimizations will not be accepted unless the performance issue rises to the level of a bug.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
|
|
|||
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