AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Persistent 504 Errors On Supabase Auth Endpoints Due To Database Connection Pool Exhaustion During Peak Hours

Project zvusdpixljxkxlxrrauj (Pro) experiences 5xx/504 errors on /auth/v1/* during weekday business hours, primarily affecting token refresh and user lookup endpoints. The issue is likely caused by database connection pool exhaustion in the GoTrue auth service under concurrent load, leading to requests exceeding the 60-second timeout.

highConfidence 70%SupabasePostgreSQLpgvectorRealtime

Origin Analysis

The GoTrue auth service is configured with an insufficient database connection pool size. During peak business hours, concurrent token refresh and user lookup operations exhaust the pool, causing requests to queue and exceed the 60-second timeout, resulting in 504 Gateway Timeout errors.
1. During peak hours (06:00-15:00 UTC weekdays), send concurrent requests to /auth/v1/token?grant_type=refresh_token and /auth/v1/user endpoints.\n2. Observe that a subset of requests hang and return 504 after 60 seconds.\n3. Check database pool metrics and note that the pool is saturated.

Fixing Code Block

Edge Case Audit

Increasing the pool size may put additional load on the PostgreSQL database, potentially degrading overall performance if the database lacks sufficient resources. Monitor database CPU, memory, and connection counts after applying the change. Consider using PgBouncer for more efficient connection pooling. To rollback, revert to the previous configuration values.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state