apache / apache/cassandra-gocql-driver
Session Timeout and Context Timeout
- Dominant language
- Go
- Stars
- 2.7k
- Forks
- 658
- PR merge metrics
- No merged PRs in 30d
Description
Looking at the "exec()" method of "Conn" in "conn.go", it seems like there's two ways we can hit a timeout condition when a Context with a deadline is provided to the Query.
As I understand it, the "Session" ClusterConfig.Timeout value is propagated to Conn which is used in the "timeoutCh" and and the Query's context is used for "ctxDone". Coming from the Datastax drivers, this is unexpected behavior.
For example, from the Python driver docs on `session.default_timeout`
> default_timeout = 10.0
A default timeout, measured in seconds, for queries executed through execute() or execute_async(). This default may be overridden with the timeout parameter for either of those methods.
Source: https://datastax.github.io/python-driver/api/cassandra/cluster.html#cassandra.cluster.Session
We don't have to copy the same behavior, but expectations are a bit unclear. I think one of the following can be done:
* better documentation/best practices around `ClusterConfig.Timeout` and/or `Query().WithContext` and timeouts. E.g. Session timeout should be 0 or very large when using Contexts to manage timeout limits.
* When Context is provided, ignore the Conn.timeout and/or call a separate 'Conn' method that only respects the context timeout, errors, and quits of the connection.
Contributor guide
Research direction
Start by reading the exec() method of Conn in conn.go, tracing how ClusterConfig.Timeout and Query().WithContext reach timeoutCh and ctxDone. Compare the current behavior with the documented expectations and determine whether the issue should be resolved through documentation or timeout handling; done requires an agreed, tested timeout policy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cassandra, go
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100