-
Notifications
You must be signed in to change notification settings - Fork 1k
Replication uses huge amounts of memory (~53GB after ~20 hours running) #498
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
Comments
Hi together, I looked deeper into this issue and found the root cause. Because of the following hack all string values from rows (selecting rows from MySQL) are referencing the data slice ("buffer") you are using for reading the packets from the MySQL connection: https://github.com/siddontang/go/blob/master/hack/hack.go#L10 Because I put this string in some kind of long term in memory database the data slices ("buffer") are never garbage collected! I proofed in detail by printing the underlying storage pointers from the data slice and from the final string after reading the rows: they are the same! Right now I fixed the problem by doing a string copy where I copy the underlying storage from the string: copiedColumnValue = string([]byte(columnValueFromGoMysqlLibrary)) (I didnot find another way) This one was really nasty but I learned a lot about Gos memory handling :) From my point of view this should be fixed like the following:
Thanks for your help, |
here is my pprof of the same issue
hope it helps |
Hi together,
I am using go-mysql replication feature and after running for roughly 20 hours it already consumes ~53GB of ram.
go tool pprof http://10.10.23.91:6060/debug/pprof/heap:
Using "list ReadPacket" in pprof I get the following:
My environment:
Some other friend of mine is running version be37886 and he does not have the same issue. When I compare the 2 versions I see that sync.Pool has been introduced:
https://github.com/siddontang/go-mysql/compare/be3788669bb4..803944a6e4ea#diff-ff50afcdad18dfa11cc6ca7509e863d6R82
To get a feeling about the "replication amount" see a list of my binlogs:
Any idea how to fix this? I know that you use sync.Pool to lower GC pressure of course. A quick fix would probably be to remove sync.Pool but I do not know if this is the right way.
Thanks for your help!
The text was updated successfully, but these errors were encountered: