Open
Description
Long story short
TCPConnector by default uses _DNSCacheTable and this table only grows, no matter how many expired records it has. Simply put, it's memory leak.
Also, it uses fixed TTL, instead of real TTL of record. I'm aware getaddrinfo
doesn't return TTL for record, but aiodns
does.
Expected behaviour
Expired cache records get evicted.
Actual behaviour
Expired DNS records stored forever.
Steps to reproduce
Normal, documented usage.
Your environment
Any valid environment.
Full story
I've created this issue to highlight memory leak issue and inquire your vision of proper order of things. It'll be good to know your opinion before I or someone else even consider doing something with it.
Here is my questions:
- Why aiohttp needs own, non-compliant with standards cache in first place? Why it is trying to solve problem which
nscd
and caching resolvers do solve? Our community of asyncio users suggests aiohttp tries to avoid slow invocations ofgetaddrinfo
via thread pool, but I'd rather ask. - Which solution you likely approve? I see following options:
- Schedule eviction of added records via heapq and perform it in lazy fashion, on cache add/query operations. This also will allow to implement independent TTL for records in future.
- Allow users to specify own DNS table class.
- Both of it.