-
Notifications
You must be signed in to change notification settings - Fork 125
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
SNOW-1563083: database/sql driver caches cancelled context #1186
Comments
hi and thank you for raising this issue with us; additionally providing all these details and the reproduction is very much appreciated ! we'll take a look |
Any update @sfc-gh-dszmolka ? |
I'm keeping all issues updated when there's progress on them - at this moment, i have no update. Issues are addressed by their respective teams in terms of the impact they have. This repo is constantly monitored, however we cannot guarantee any specific timeline for resolution in advance. Thank you for your understanding! |
#1196 merged - thank you for the contribution! will be released with the next upcoming driver release |
released with gosnowflake v.1.11.1 |
Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!
What version of GO driver are you using?
github.com/snowflakedb/gosnowflake v1.10.1
What operating system and processor architecture are you using?
run
go version
in your consoleServer version:
8.27.1
What did you do?
If a
*sql.DB
instance is opened withsql.OpenDB(connector)
, then cancelling the context provided todb.QueryContext
after the query has completed will result in warnings getting logged that the context is already closed when "recycling" the connection. I've reproduced a minimal example below, but the real-world scenario this comes up in is iferrgroup
is used to dispatch multiple queries concurrently. Once youWait()
for the group to finish, the group's context is cancelled. The problem is that the driver currently attempts to reuse this context in the call todefer db.Close()
later when the function exits.Based on my investigation, this seems like it has to do with the db connection pooling that Go's
database/sql
provides automatically. If you uncomment the linedb.SetMaxIdleConns(0)
, then the error does not occur. I believe this is because it prevents Go from caching the connection.In order for
database/sql
connections to be persist-able within the cache, they should not store the context from the query that spawned them since it may have a shorter lifetime than the connection if it is reused. The docs indicate this as well:Expected
Actual
Can you set logging to DEBUG and collect the logs?
https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors
What is your Snowflake account identifier, if any? (Optional)
The text was updated successfully, but these errors were encountered: