Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Exec memory leak ? #451

Closed
arsssen opened this issue Oct 16, 2018 · 4 comments · Fixed by #452
Closed

.Exec memory leak ? #451

arsssen opened this issue Oct 16, 2018 · 4 comments · Fixed by #452

Comments

@arsssen
Copy link

arsssen commented Oct 16, 2018

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 ?

@CMogilko
Copy link
Member

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

@arsssen
Copy link
Author

arsssen commented Oct 17, 2018

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.

@CMogilko
Copy link
Member

CMogilko commented Oct 17, 2018

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.

@arsssen
Copy link
Author

arsssen commented Oct 18, 2018

thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants