MagicStack / MagicStack/asyncpg
Pool connect ignores DNS ttl
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
- asyncpg version: 0.14
- PostgreSQL version: 9.5/9.6
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Using AWS RDS - Python version: 3.6
- Platform: Linux in docker
- Do you use pgbouncer?: Not in this instances
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?:
- Can the issue be reproduced under both asyncio and
uvloop?: We only use asyncio
After performing a failover/reboot of an AWS RDS instance asyncpg does not appear to reconnect gracefully - it looks like the code in Pool caches the IP of the PG instance after dns resolution and does not respect whatever TTL we might have set on the cname that points at our master: https://github.com/MagicStack/asyncpg/blob/master/asyncpg/pool.py#L133
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in asyncpg/pool.py around line 133 and trace how Pool resolves and reuses the PostgreSQL host. Check the reported AWS RDS failover scenario and how DNS changes are handled under asyncio. Done means the pool reconnects to the updated address after failover instead of retaining the old resolved IP, with regression coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100