-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Report
YDB GO SDK version:
3.112.0
Environment
go 1.24.5 MacOS
Current behavior:
If closeTimeout != 0 (default), context canceled before closeItem was called.
Expected behavior:
closeItem() executed with non-canceled context.
Steps to reproduce:
Related code:
func (p *Pool[PT, T]) closeItem(ctx context.Context, item PT, opts ...closeItemOption) {
// ...
if t := p.config.closeTimeout; t > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, t)
defer cancel() // executed on exit
}
if options.wg != nil {
options.wg.Add(1)
// wg.Wait() in the separate method, so current goroutine exited, and cancel() was invoked
go func() {
defer options.wg.Done()
p.config.closeItemFunc(ctx, item)
}()
} else {
p.config.closeItemFunc(ctx, item)
}
}
ydb-go-sdk/internal/pool/pool.go
Lines 354 to 370 in 83ae145
| if t := p.config.closeTimeout; t > 0 { | |
| var cancel context.CancelFunc | |
| ctx, cancel = context.WithTimeout(ctx, t) | |
| defer cancel() | |
| } | |
| if options.wg != nil { | |
| options.wg.Add(1) | |
| go func() { | |
| defer options.wg.Done() | |
| p.config.closeItemFunc(ctx, item) | |
| }() | |
| } else { | |
| p.config.closeItemFunc(ctx, item) | |
| } | |
| } |
Other information:
We missed this bug because we weren't checking for errors on session close.
ydb-go-sdk/internal/pool/pool.go
Lines 156 to 158 in 83ae145
| closeItemFunc: func(ctx context.Context, item PT) { | |
| _ = item.Close(ctx) | |
| }, |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working