Skip to content

Commit 4420754

Browse files
authored
Merge pull request #452 from rethinkdb/develop
fix noreply memory leak
2 parents 3d528a7 + 493b055 commit 4420754

File tree

4 files changed

+6
-31
lines changed

4 files changed

+6
-31
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## v5.0.1 - 2018-10-18
6+
7+
- Fix noreply queries memory leak due unnecessary for responses
8+
59
## v5.0.0 - 2018-09-12
610

711
- Moved to rethinkdb organization

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
![RethinkDB-go Logo](https://raw.github.com/wiki/rethinkdb/rethinkdb-go/gopher-and-thinker-s.png "Golang Gopher and RethinkDB Thinker")
1010

11-
Current version: v5.0.0 (RethinkDB v2.3)
11+
Current version: v5.0.1 (RethinkDB v2.3)
1212

1313
Please note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work).
1414

connection.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,7 @@ func (c *Connection) Query(ctx context.Context, q Query) (*Response, *Cursor, er
209209
}
210210

211211
if noreply, ok := q.Opts["noreply"]; ok && noreply.(bool) {
212-
select {
213-
case c.readRequestsChan <- tokenAndPromise{ctx: ctx, query: &q, span: fetchingSpan}:
214-
return nil, nil, nil
215-
case <-ctx.Done():
216-
return c.stopQuery(&q)
217-
}
212+
return nil, nil, nil
218213
}
219214

220215
promise := make(chan responseAndCursor, 1)

connection_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,6 @@ func (s *ConnectionSuite) TestConnection_Query_NoReplyOk(c *test.C) {
143143
conn.AssertExpectations(c)
144144
}
145145

146-
func (s *ConnectionSuite) TestConnection_Query_NoReplyTimeoutWrite(c *test.C) {
147-
ctx, cancel := context.WithCancel(context.Background())
148-
token := int64(1)
149-
q := testQuery(DB("db").Table("table").Get("id"))
150-
q.Opts["noreply"] = true
151-
writeData := serializeQuery(token, q)
152-
stopData := serializeQuery(token, newStopQuery(token))
153-
154-
conn := &connMock{}
155-
conn.On("Write", writeData).Return(len(writeData), nil)
156-
conn.On("Write", stopData).Return(len(stopData), nil)
157-
conn.On("SetWriteDeadline").Return(nil)
158-
159-
connection := newConnection(conn, "addr", &ConnectOpts{ReadTimeout: time.Millisecond, WriteTimeout: time.Millisecond})
160-
connection.readRequestsChan = make(chan tokenAndPromise, 0)
161-
cancel()
162-
response, cursor, err := connection.Query(ctx, q)
163-
164-
c.Assert(response, test.IsNil)
165-
c.Assert(cursor, test.IsNil)
166-
c.Assert(err, test.Equals, ErrQueryTimeout)
167-
conn.AssertExpectations(c)
168-
}
169-
170146
func (s *ConnectionSuite) TestConnection_Query_TimeoutWrite(c *test.C) {
171147
ctx, cancel := context.WithCancel(context.Background())
172148
token := int64(1)

0 commit comments

Comments
 (0)