Recurrent PostgreSQL Connection Issues β ConnectionDoesNotExistError using asyncpg
Hello, im experiencing recurring connection issues with my PostgreSQL database hosted on Supabase. My application (a Discord bot written in Python) is encountering the following error during database operations:
Technical Details:
Application Context:
asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operationTechnical Details:
- Library: asyncpg (Python)
- Operation Type: Simple SQL query execution
- Frequency: Multiple occurrences in the past 6 hours (previously ran for over 4 months without issues)
File "/application/.local/lib/python3.13/site-packages/asyncpg/connection.py", line 352, in execute asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operationApplication Context:
- The Discord bot has been running 24/7 for over 4 months on a server
- Connections are created on demand for each operation
- I am not currently using a connection pool
- Is there a timeout for idle connections on Supabase?
- Are there any recommended configurations for long-running applications?
- Would you recommend using connection pooling for this kind of application?