Pool.Close blocks indefinitely when a panic happens during iteration of statement rows #73
Answered
by
zombiezen
comunidadio
asked this question in
Q&A
-
Managed to reproduce the issue with a minimal testcase: package main
import (
"context"
"zombiezen.com/go/sqlite/sqlitex"
)
var dbpool *sqlitex.Pool
func init() {
var err error
dbpool, err = sqlitex.NewPool("file::memory:?mode=memory", sqlitex.PoolOptions{})
if err != nil {
panic(err)
}
}
func fini() {
fmt.Println("i will block now...")
dbpool.Close() // this blocks indefinitely
}
func querySomething() {
conn := dbpool.Get(context.Background())
defer dbpool.Put(conn)
stmt := conn.Prep("SELECT 1")
stmt.Step()
panic("some error happened while iterating results...")
}
func main() {
defer fini()
querySomething()
} |
Beta Was this translation helpful? Give feedback.
Answered by
zombiezen
Jan 25, 2024
Replies: 1 comment 2 replies
-
Thanks for the minimal reproducer. It seems that what happens here is that there is an additional panic during |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
comunidadio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the minimal reproducer. It seems that what happens here is that there is an additional panic during
dbpool.Put
because the connection has a pending statement. If you add adefer stmt.Reset()
afterconn.Prep
, the program completes as expected.