Skip to content

.Exec memory leak ? #451

Closed
Closed

Description

@arsssen

Consider the following code:

package main

import r "gopkg.in/rethinkdb/rethinkdb-go.v5"


func main() {
	session, err := r.Connect(r.ConnectOpts{Address: "localhost:28015"})
	if err != nil {
		return
	}
	execOpts := r.ExecOpts{NoReply: true}
	insertOpts := r.InsertOpts{Conflict: "update"}
	t := r.DB("test_db").Table("test_table")

	for {
		err = t.Insert(r.JSON(`{"id":"xxx", "a": 1}`), insertOpts).Exec(session, execOpts)
		if err != nil {
			return
		}
	}

}

when running this for around 1-2 minutes memory usage reaches 15GB

when using .Run instead of .Exec memory usage stays at ~10MB

Is there a memory leak here or I'm doing something wrong ?

Activity

  1. CMogilko commented on Oct 16, 2018

    @CMogilko
    Member

    It's connection leak. It seems that Exec doesn't close cursor or something. I need to investigate this.

  2. arsssen commented on Oct 17, 2018

    @arsssen
    Author

    Thank you.

    Is there any workaround ATM ? We have a huge amount of writes and Run (even with durability:soft) is too slow for that.

  3. CMogilko commented on Oct 17, 2018

    @CMogilko
    Member

    Try to parse json into go map[string]interface{} on the client side, it seems that server's r.JSON doesn't so effective. Also batch inserts are much faster. For example insert array of 1000 documents in a single query.

  4. arsssen commented on Oct 18, 2018

    @arsssen
    Author

    thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions