diff --git a/CHANGELOG.md b/CHANGELOG.md index 908b97a4..30fa3682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 8a59b965..61d719c0 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/connection.go b/connection.go index 7a98336b..4c64b2d9 100644 --- a/connection.go +++ b/connection.go @@ -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) diff --git a/connection_test.go b/connection_test.go index ffe2498b..b96526e5 100644 --- a/connection_test.go +++ b/connection_test.go @@ -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)