-
Notifications
You must be signed in to change notification settings - Fork 906
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
Context support #786
Comments
Slightly related to #667 |
I'd like to push for support aswell, i had a heck of a time debugging why the database connection has such an insanely long timeout when the database is unresponsive! The database was also ignoring the timeout context it was being given, and with a default timeout of 42 seconds!!! (in my case a timeout of at MOST 5 second is plenty!!) |
Long story short. Support for *Context would be highly appreciated for timeout but also expensive query cancellation in case upstream no longer cares for the query result. |
I'm not aware of a reason to use lib/pq over pgx. It's better supported, more correct, and is faster. |
@basvanbeek For me, ocsql was complaining that it was missing the Context* methods in the sql driver, and could not continue. Perhaps this was a bug or missing feature that has been implemented since I last tried it? I'm now using pgx so it's all fine now. @mjibson |
I might be missing something, but isn't it implemented here? Line 13 in 0ac245b
|
@cgilling I was wondering the same thing (we are using This happens in the simplest cases, and even when a span is manually created just before the query, like in the example below.
In this case the new span will be correctly correlated to the parent span but the query will be its own separate trace. I have tested This leads me to believe that there is some issue with how the context is handled, but I was at this point unable to discover what exactly is the issue. |
It seems lib/pq does not support driver.StmtQueryContext and driver.StmtExecContext. It only implements the Context methods on a driver.Conn. ocsql tries to be transparent to sql/database on which enhancement interfaces are implemented. It hides interfaces not implemented by the underlying driver. In this case this means a userland call to stmt.QueryRowContext in database/sql is sent to driver's stmt.Query thus dropping the context. Best would be for lib/pq to implement these functions. |
@basvanbeek thanks for the explanation. Turns out there is actually a pr pending for exactly this: #768 |
Any update on this? The PR is still open. |
Does #839 fix this? |
@Gunni I don't think so since functions like |
This bug is now 5 years old, starting primary school soon, I wonder if it will ever be fixed... |
I'd like for pq to support the *Context calls.
In one of my projects I started using github.com/basvanbeek/ocsql. It wraps the driver and adds OpenCensus tracing. This works great, even when wrapping the sql.DB with sqlx for extra functionality. However, it requires the driver to support Context calls as defined in the stdlib (BeginTx, ExecContext, etc.). Therefore, I (temporarily?) switched to [github.com/jackc/pgx/stdlib](https://godoc.org/github.com/jackc/pgx/stdlib
I think that pg should support these functions. https://golang.org/pkg/database/sql/driver
The text was updated successfully, but these errors were encountered: