Skip to content

Commit

Permalink
Merge pull request #452 from rethinkdb/develop
Browse files Browse the repository at this point in the history
fix noreply memory leak
  • Loading branch information
CMogilko authored Oct 18, 2018
2 parents 3d528a7 + 493b055 commit 4420754
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## v5.0.1 - 2018-10-18

- Fix noreply queries memory leak due unnecessary for responses

## v5.0.0 - 2018-09-12

- Moved to rethinkdb organization
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

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

Current version: v5.0.0 (RethinkDB v2.3)
Current version: v5.0.1 (RethinkDB v2.3)

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).

Expand Down
7 changes: 1 addition & 6 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,7 @@ func (c *Connection) Query(ctx context.Context, q Query) (*Response, *Cursor, er
}

if noreply, ok := q.Opts["noreply"]; ok && noreply.(bool) {
select {
case c.readRequestsChan <- tokenAndPromise{ctx: ctx, query: &q, span: fetchingSpan}:
return nil, nil, nil
case <-ctx.Done():
return c.stopQuery(&q)
}
return nil, nil, nil
}

promise := make(chan responseAndCursor, 1)
Expand Down
24 changes: 0 additions & 24 deletions connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,30 +143,6 @@ func (s *ConnectionSuite) TestConnection_Query_NoReplyOk(c *test.C) {
conn.AssertExpectations(c)
}

func (s *ConnectionSuite) TestConnection_Query_NoReplyTimeoutWrite(c *test.C) {
ctx, cancel := context.WithCancel(context.Background())
token := int64(1)
q := testQuery(DB("db").Table("table").Get("id"))
q.Opts["noreply"] = true
writeData := serializeQuery(token, q)
stopData := serializeQuery(token, newStopQuery(token))

conn := &connMock{}
conn.On("Write", writeData).Return(len(writeData), nil)
conn.On("Write", stopData).Return(len(stopData), nil)
conn.On("SetWriteDeadline").Return(nil)

connection := newConnection(conn, "addr", &ConnectOpts{ReadTimeout: time.Millisecond, WriteTimeout: time.Millisecond})
connection.readRequestsChan = make(chan tokenAndPromise, 0)
cancel()
response, cursor, err := connection.Query(ctx, q)

c.Assert(response, test.IsNil)
c.Assert(cursor, test.IsNil)
c.Assert(err, test.Equals, ErrQueryTimeout)
conn.AssertExpectations(c)
}

func (s *ConnectionSuite) TestConnection_Query_TimeoutWrite(c *test.C) {
ctx, cancel := context.WithCancel(context.Background())
token := int64(1)
Expand Down

0 comments on commit 4420754

Please sign in to comment.