Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectContext does not cancel when context is timed out #895

Open
itschrispeck opened this issue Sep 26, 2023 · 1 comment
Open

SelectContext does not cancel when context is timed out #895

itschrispeck opened this issue Sep 26, 2023 · 1 comment

Comments

@itschrispeck
Copy link

I'm using the SelectContext method, and trying to timeout the context to cancel indefinitely running queries. It appears that the timeout is not respected, and the goroutine hangs forever. It seems that SelectContext should respect context.WithTimeout.

Code:

ctx, cancel := context.WithTimeout(ctx, _defaultTimeout)
defer cancel()

return g.DB.SelectContext(ctx, dest, query, args...)

SIGQUIT trace:

goroutine 158 [sync.RWMutex.RLock, 52 minutes]:
--
runtime.gopark(0x4?, 0xd0?, 0x20?, 0xc1?, 0x1?)
GOROOT/src/runtime/proc.go:398 +0xce fp=0xc00147d100 sp=0xc00147d0e0 pc=0x1c4f1ee
runtime.goparkunlock(...)
GOROOT/src/runtime/proc.go:404
runtime.semacquire1(0xc0093ca1f4, 0x0?, 0x3, 0x0, 0x39?)
GOROOT/src/runtime/sema.go:160 +0x218 fp=0xc00147d168 sp=0xc00147d100 pc=0x1c60738
sync.runtime_SemacquireRWMutexR(0x4e4f495449545241?, 0x20?, 0x4e49462027313230?)
GOROOT/src/runtime/sema.go:82 +0x25 fp=0xc00147d1a0 sp=0xc00147d168 pc=0x1c7eb05
sync.(*RWMutex).RLock(...)
GOROOT/src/sync/rwmutex.go:71
database/sql.(*Rows).Columns(0xc0093ca1b0)
GOROOT/src/database/sql/sql.go:3111 +0x65 fp=0xc00147d248 sp=0xc00147d1a0 pc=0x265bd25
github.com/jmoiron/sqlx.(*Rows).Columns(0xb62638?)
<autogenerated>:1 +0x1f fp=0xc00147d260 sp=0xc00147d248 pc=0x2c5685f
github.com/jmoiron/sqlx.scanAll({0xb43a20?, 0xc0011a4050?}, {0x328860, 0xc004b7af90}, 0x0)
external/com_github_jmoiron_sqlx/sqlx.go:924 +0x253 fp=0xc00147d3f8 sp=0xc00147d260 pc=0x2c52253
github.com/jmoiron/sqlx.SelectContext({0xb40368?, 0xc0008c2190?}, {0xb33c60?, 0xc001609bf0?}, {0x328860, 0xc004b7af90}, {0x85b081?, 0x18?}, {0x0, 0x0, ...})
external/com_github_jmoiron_sqlx/sqlx_context.go:61 +0xf0 fp=0xc00147d478 sp=0xc00147d3f8 pc=0x2c52fb0
github.com/jmoiron/sqlx.(*DB).SelectContext(...)
external/com_github_jmoiron_sqlx/sqlx_context.go:140
<...>
@salvadorcea
Copy link

I am facing the same problem, did you find any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants