"Max client connections reached" on Transaction Pooler
Problem
How I Got Here
I am trying to connect a backend service to Supabase's database. Originally I was not having issues, but then it started reaching the maximum client connections on Supabase and therefore losing connection (?) and crashing. The service needs a constant connection to the database to continue running so it is easy to tell when something has gone wrong as the whole service stops. Around the time it started having issues, nothing was changed with the database settings nor the service code. It has been like this for around a day so far, after being fine for a couple weeks at least.What Does Not Work (Worked Previously)
- Connecting to Supabase database transaction pooler via Java service
- Connecting to Supabase database transaction pooler via command prompt (
psql postgresql://postgres.xxxxxxxxxxxxx:xxxxxxxxxxxxxxxx@aws-1-us-east-2.pooler.supabase.com:6543/postgres) with service suspended, so no other users
- Connecting to Supabase auth
- "Table Editor", "SQL Editor" via browser
- Connecting to Supabase database session pooler via command prompt
- Supabase: Nano, us-east-2, default if not higher pool size
- Service: Java + Spring Boot + JDBC, server is IPv4 only
- Environment variables below (no other database-related environment variables):
- Environment variables below (no other database-related environment variables):
- CLI psql: v16.3
- Dashboard "Reports/Database" indicates that before and during the issue, database connections did not exceed 10 total at any time
- Suspend service for extended time (1h) and retry connection
- Restart Supabase project and immediately try connecting
- Restart Supabase service and wait a while doing nothing with it, then try connecting
- Change service environment variables to reduce number of attempted connections and decrease timeout times
- Add
SPRING_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLDto service environment (service cannot start without getting a connection initially, so it has not helped) - Use session pooler instead of transaction pooler for service; this works for a few minutes (e.g. 30 mins) before stopping the service due to a different error:
o.h.engine.jdbc.spi.SqlExceptionHelper : HikariPool-1 - Connection is not available, request timed out after 30001ms; I have spent lots of time on this already and could not figure out a solution but that's a separate thing
Using the Supabase database transaction pooler has worked fine for me for days, but then suddenly started constantly being at max client connections, even across restarts of the Supabase project. Nothing really happened around the time this started, and I have reason to believe I am not actually at the maximum number of connections. Connecting via the session pooler has a different issue (perhaps due to how I set it up?) that I discovered much earlier so I cannot use that either. How can I fix one of the two pooler issues so I can have a working connection?