Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
database/sql: driver.Stmt.Close is called twice #16019
Please answer these questions before submitting your issue. Thanks!
reproducible example is here
No error log shown.
It means Stmt.Close() is called twice. First stack trace is:
And second is:
Possible solution is:
"Possible solution" I wrote above cause another race.
Another possible solution is:
(I haven't tested this because it's midnight in Japan)
I don't see anything in the current database/sql code that prevents driver.Stmt.Close from being closed more than once. It will prevent it from being called concurrently, but nothing prevents it from being called twice.
My recommendation is to document that driver.Stmt.Close may be called more than once and further calls should be idempotent.
Also, there is currently a code path where if driver.Stmt.Close panics the sql pool will lock up due to a held lock. This is in
Do not retain a lock when driver.Stmt.Close panic as the rest of the sql package ensures. Updates #16019 Change-Id: Idc7ea9258ae23f491e79cce3efc365684a708428 Reviewed-on: https://go-review.googlesource.com/33328 Run-TryBot: Brad Fitzpatrick <email@example.com> Reviewed-by: Brad Fitzpatrick <firstname.lastname@example.org>