Repository navigation
fix(realtime): retry the initial session check and serialize sweeps - #600
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Follow-up from the deployed change. Two background realtime session sweeps reported a Postgres connection timeout during a three-hour observation window. Request-ID correlation found one successful WebSocket upgrade (101) and one MCP POST (400). The logs do not establish that the sweep caused the 400. No token route recorded a timeout in that window. In a subsequent database snapshot, 13 database client connections were visible against a limit of 60, with zero lock waits. That later snapshot cannot establish pooler capacity at the time of the failures. The one-retry guard remains justified. To distinguish a pooler refusal, network delay, and a suspended function, compare historical pooler accept/connection metrics with the two application event times on November 18, 15:27:36 and 15:43:51 UTC. An additional application retry would obscure that distinction. |
|
Checked the Tokyo project’s Supavisor and Postgres logs for November 18, 15:24 to 15:47 UTC, using the application event times. All 908 pooler records were reviewed. They contained 380 client authentications, 154 backend authentications, 359 client terminations and 15 idle socket closures. The dashboard reported zero warnings and zero errors. Postgres recorded four routine checkpoint start/completion pairs. Within 60 seconds on either side of 15:27:36 UTC, the pooler logged 37 client and 15 backend authentications. At 15:43:51 UTC the corresponding counts were 26 and 11. There was no logged pool exhaustion, authentication refusal or backend connection failure. The records do not identify Orbit’s individual failed attempts, so application-to-pooler connection establishment remains unresolved. These observations provide no basis for changing the pool size, timeouts or retry count. |
What this changes
When the first database connection times out during a realtime session sweep, retry the read once and use the current time to check session expiry. Keep one sweep in flight per hub. If a connection closes or is replaced while the database read is pending, the result is applied only to the connection that started the check.
Why
Production logged session sweeps failing with
CONNECT_TIMEOUTon websocket and MCP requests. The change covers this session read without repeating application writes. Repeated failures remain visible in the runtime logs.Verification
Forty focused checks and five native Node cases covered connection startup failure, expiry during a retry, overlapping sweeps and hub shutdown. No database migration is required.\n
All six CI jobs passed, including both browser suites. The unit job recorded 7,495 passing tests including the Docker gateway checks. Five object storage cases were skipped in CI. The Vercel preview reached READY on
47a4863dand its database compatibility check passed.