Skip to content

Commit 4278a30

Browse files
committed
Fix issue where a timeout closes the connection.
As part of CASSGO-12 which was supposedly just removing deprecated code, the driver now closes connections when a timeout occurs which was unintended. This patch fixes this issue. patch by João Reis; reviewed by TBD for CASSGO-87
1 parent a6e8291 commit 4278a30

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6565

6666
### Fixed
6767

68+
#### 2.0.0
69+
70+
- Driver closes connection when timeout occurs (CASSGO-87)
71+
6872
#### 2.0.0-rc1
6973

7074
- Cassandra version unmarshal fix (CASSGO-49)

conn.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ type Conn struct {
199199
ctx context.Context
200200
cancel context.CancelFunc
201201

202-
timeouts int64
203-
204202
logger StructuredLogger
205203
}
206204

@@ -753,12 +751,6 @@ func (c *Conn) releaseStream(call *callReq) {
753751
}
754752
}
755753

756-
func (c *Conn) handleTimeout() {
757-
if atomic.AddInt64(&c.timeouts, 1) > 0 {
758-
c.closeWithError(ErrTooManyTimeouts)
759-
}
760-
}
761-
762754
func (c *Conn) recvSegment(ctx context.Context) error {
763755
var (
764756
frame []byte
@@ -1325,7 +1317,6 @@ func (c *Conn) execInternal(ctx context.Context, req frameBuilder, tracer Tracer
13251317
close(call.timeout)
13261318
c.logger.Debug("Request timed out on connection.",
13271319
newLogFieldString("host_id", c.host.HostID()), newLogFieldIp("addr", c.host.ConnectAddress()))
1328-
c.handleTimeout()
13291320
return nil, ErrTimeoutNoResponse
13301321
case <-ctxDone:
13311322
c.logger.Debug("Request failed because context elapsed out on connection.",
@@ -1990,9 +1981,13 @@ func (c *Conn) awaitSchemaAgreement(ctx context.Context) (err error) {
19901981
}
19911982

19921983
var (
1993-
ErrQueryArgLength = errors.New("gocql: query argument length mismatch")
19941984
ErrTimeoutNoResponse = errors.New("gocql: no response received from cassandra within timeout period")
1995-
ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection")
19961985
ErrConnectionClosed = errors.New("gocql: connection closed waiting for response")
19971986
ErrNoStreams = errors.New("gocql: no streams available on connection")
1987+
1988+
// Deprecated: TimeoutLimit was removed so this is never returned by the driver now
1989+
ErrTooManyTimeouts = errors.New("gocql: too many query timeouts on the connection")
1990+
1991+
// Deprecated: Never returned by the driver
1992+
ErrQueryArgLength = errors.New("gocql: query argument length mismatch")
19981993
)

0 commit comments

Comments
 (0)