Existing issues
Affected area
Auth
Problem to solve
The local Auth container keeps no idle Postgres connections. With GOTRUE_DB_MAX_IDLE_POOL_SIZE and GOTRUE_DB_CONN_PERCENTAGE unset, GoTrue's fixed pool strategy (internal/storage/dial.go) calls SetMaxIdleConns(0). Every Auth request then opens and closes its own database connection, and each closed socket sits in TIME_WAIT for 60s inside the Auth container.
Under a concurrent integration-test suite against supabase start, this exhausts the container's ephemeral ports (32768–60999). The symptom is random Auth failures, for example in user creation.
Repro, CLI 2.117.0, Auth image gotrue:v2.197.0: 20 password-grant requests sent from inside supabase_auth_<project> raised its TIME_WAIT sockets from 6 to 26, one per request.
The CLI gives no way to change this:
- The
[auth] config has no pool key.
- The Auth env builder sets only
GOTRUE_DB_DRIVER and GOTRUE_DB_DATABASE_URL, with no extra-env passthrough.
supabase stop prunes containers, so an Auth container recreated by hand with extra env does not survive a restart.
Hosted Auth does get a pool sized as a percentage or an absolute number (supabase/supabase#50932), so local differs from production here.
Proposed solution
Either of these:
-
Expose the Auth DB pool in config.toml, for example:
[auth]
db_max_pool_size = 10
db_max_idle_pool_size = 10
db_conn_max_idle_time = "60s"
These map to GOTRUE_DB_MAX_POOL_SIZE, GOTRUE_DB_MAX_IDLE_POOL_SIZE and GOTRUE_DB_CONN_MAX_IDLE_TIME.
-
Default the local Auth container to a non-zero idle pool, matching hosted.
Alternatives considered
- Recreating the Auth container with extra env after
supabase start. The next supabase stop / start undoes it, and it means copying about 100 CLI-built env vars, labels and network settings by hand.
- Capping test concurrency. This works around the port exhaustion but does not remove it.
Additional context
Related: #6922, where the HTTP gateway opened a new upstream connection per request and exhausted ephemeral ports.
Existing issues
Affected area
Auth
Problem to solve
The local Auth container keeps no idle Postgres connections. With
GOTRUE_DB_MAX_IDLE_POOL_SIZEandGOTRUE_DB_CONN_PERCENTAGEunset, GoTrue's fixed pool strategy (internal/storage/dial.go) callsSetMaxIdleConns(0). Every Auth request then opens and closes its own database connection, and each closed socket sits in TIME_WAIT for 60s inside the Auth container.Under a concurrent integration-test suite against
supabase start, this exhausts the container's ephemeral ports (32768–60999). The symptom is random Auth failures, for example in user creation.Repro, CLI 2.117.0, Auth image
gotrue:v2.197.0: 20 password-grant requests sent from insidesupabase_auth_<project>raised its TIME_WAIT sockets from 6 to 26, one per request.The CLI gives no way to change this:
[auth]config has no pool key.GOTRUE_DB_DRIVERandGOTRUE_DB_DATABASE_URL, with no extra-env passthrough.supabase stopprunes containers, so an Auth container recreated by hand with extra env does not survive a restart.Hosted Auth does get a pool sized as a percentage or an absolute number (supabase/supabase#50932), so local differs from production here.
Proposed solution
Either of these:
Expose the Auth DB pool in
config.toml, for example:These map to
GOTRUE_DB_MAX_POOL_SIZE,GOTRUE_DB_MAX_IDLE_POOL_SIZEandGOTRUE_DB_CONN_MAX_IDLE_TIME.Default the local Auth container to a non-zero idle pool, matching hosted.
Alternatives considered
supabase start. The nextsupabase stop/startundoes it, and it means copying about 100 CLI-built env vars, labels and network settings by hand.Additional context
Related: #6922, where the HTTP gateway opened a new upstream connection per request and exhausted ephemeral ports.