Open LCBHSStudent opened 1 year ago
Same issue with Tornado. Basically, even if connection doesn't expect SSL the asyncpg try to use it. As we know, if SSL connection was cancel it provide leak - https://github.com/python/cpython/issues/109534#issuecomment-1865257133
Also, seems like this line https://github.com/MagicStack/asyncpg/blob/master/asyncpg/connection.py#L471 is leak. (sorry, it's different issue I believe)
0.2.7
PostgreSQL 13.3 (Debian 13.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
kartoza/postgis:pr-333-13-3.1
3.8.10
20.04.1-Ubuntu x86_64
sqlalchemy
)Background: I built a simple web server using
sqlalchemy
andsanic
, then created a request handler function that can query my local PostgreSQL server running in docker. However, I saw continuous memory increase while benching my handler function.After running
tracemalloc
for help, I got the result below:The code for creating the async_engine is:
At first, I tried adding
?ssl=disable
after the previous connect string in order to preventconnect_utils._create_ssl_connection
calls, and it works. Then, I tried to make some stupid changes to the source code ofasyncpg
, because I think this SSL transport is not closed after creating new transport. (I'm not sure is that correct)Finally, I modified the code starts from line 702 to:
After this modification, my web server keeps working fine, but I don't know whether this is a proper modification.
If you have any questions or ideas, please let me know, thank you so much!