fix: Add database connection pool configuration for GOTRUE#396
Open
everettbu wants to merge 1 commit into
Open
fix: Add database connection pool configuration for GOTRUE#396everettbu wants to merge 1 commit into
everettbu wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of supabase/supabase#41492
Original author: krishvsoni
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Fixes #41033 - Supabase Auth API leaks connections
The Supabase Auth service (GoTrue) was creating unlimited database connections during high-load authentication scenarios, leading to connection exhaustion and "cannot assign requested address" errors. This occurred because the Auth service lacked explicit connection pool configuration in the Docker setup, causing it to use default values that were insufficient for concurrent authentication requests.
What is the new behavior?
The Auth service now has proper connection pool configuration with:
GOTRUE_DB_MAX_POOL_SIZE=10(configurable via environment variables)GOTRUE_DB_MAX_POOL_SIZE_UNIT=connections(absolute connection limit)This prevents connection exhaustion by limiting the number of concurrent database connections the Auth service can establish, ensuring stable performance during high-load authentication operations.
Additional context
Root Cause
The Auth service connects to PostgreSQL but lacked explicit connection pooling limits in the default Docker configuration. During high-load scenarios (multiple concurrent sign-ups/sign-ins), this caused the service to exhaust system resources and fail with connection errors.
Changes Made
docker/docker-compose.yml: Added environment variables to the auth service:
docker/.env.example: Added default configuration values:
Testing
The fix can be verified by:
docker compose up -dVerification Results:
Database Connection Query Results:
Output:
Configuration Notes
This fix resolves the connection leak issue reported in the Supabase community and ensures stable Auth service performance under load.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.