-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
Memory leak in long-lived connection pool #1081
Comments
Do you have a self contained reproduction? |
I've tried to write a reproduction script, but it doesn't leak memory. If there is a bug in |
@seanlinsley is there any update on this? I am seeing similar things (queries with many parameters) increasing memory usage quite heavily. |
We haven't been able to reproduce this outside of our production environment, even after building a load tester with similar queries. For now it's been sufficient to prune old connections as described in bikeshedder/deadpool#273 |
Ok,...well, I am trying to reproduce this right now in a minimal example. Hopefully I will manage,... |
I assume you are using the deadpool / pgsql combination in a webserver, correct? If so, what is the underlying web framework? |
@seanlinsley can you give some details about your production environment? Are you using a web framework? Could it be that the executable is running in a container environment like Kubernetes, Openshift etc.? Does that container environment enforce memory limits?... |
@sfackler my tests suggest that frequently used connections have ~100MByte of memory reserved at rest. So they pretty much never free that memory. Having a connection pool of 25 clients could take up ~2.5GByte of memory which seems to be quite a lot. |
It seems that the memory is allocated mostly in the read- and write-buffer of the
|
In the image below, memory usage is stable with
prune_db_connections
as described in bikeshedder/deadpool#273, plusmalloc_trim(0)
. Then disablingprune_db_connections
shows a clear memory leak.Heaptrack shows two leaks, both around
BytesMut
usage:Related discussions online:
Possible debugging steps:
Possible fixes:
BytesMut
usage and not something like closed connections never being freed. and it'd be a good opportunity to confirm/deny the performance difference that motivated the change originallyThe text was updated successfully, but these errors were encountered: