Repository navigation
fix(bbb-graphql-server): lower connection_lifetime to limit Postgres memory growth - #25310
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughIn Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
a7af081 to
de8bd4a
Compare
…memory growth The BigBlueButton source in bbb-graphql-server metadata keeps each Postgres connection alive for 1 hour (connection_lifetime: 3600). While a connection stays open, Postgres holds onto the memory it used and never returns it to the system, so a 1-hour lifetime with up to 100 connections lets several GB pile up across a workday and pushes hosts into swap. Lowering it to 300 (the value validated in the investigation) recycles connections while still under load, so per-connection memory stays bounded. The cost is one reconnect per connection every 5 minutes, negligible next to the graphql server's constant query polling. Co-Authored-By: Tiago Jacobs <[email protected]>
de8bd4a to
87e9019
Compare
ab7b61f
into
bigbluebutton:v3.0.x-develop
|
🚨 Automated tests failed |



Summary
The
BigBlueButtonsource inbbb-graphql-server/metadata/databases/databases.yamlkeeps each Postgres connection alive for 1 hour (connection_lifetime: 3600). This lowers it to300(5 minutes) - the value tested in the investigation.It is a one-line change, but it fixes a real memory problem, shown in the charts below.
The problem
On busy BBB 3.x servers, Postgres memory grows through the day and never comes back down, even when load drops. Over a workday this pushes servers into swap, and the visible result is audio joins timing out during the busiest hours.
A snapshot of 5 production hosts:
Almost every connection belongs to the BBB graphql server's pool, sits idle, and was used less than a minute ago. The last column matters:
idle-in-transactionis 0 on every host, which rules out the most common fix people try first.Why it happens
The BBB graphql server keeps a pool of Postgres connections and reuses them. While a connection stays open, Postgres holds onto the memory it used to run queries and does not give it back to the system. The only thing that frees that memory is closing the connection.
The pool closes a connection after it has been idle for 180 seconds, or after it has lived for
connection_lifetime. During a busy day the pool is never idle for 180 seconds (the graphql server queries it constantly), so the only thing recycling connections isconnection_lifetime: 3600- one full hour. With up to 100 connections each holding memory for an hour, several GB pile up and never get returned.Each line below is one connection. Its memory only goes up, never down, for as long as it lives:
Why the usual fixes don't work
idle_in_transaction_session_timeout- there are no idle-in-transaction connections (the pool is plain idle), so there is nothing for it to act on.idle_session_timeout- Postgres resets this timer on every query. The graphql server queries the pool constantly, so no connection is ever idle long enough for it to fire. Tested at 300s: no effect.There is also a trap that hides the bug in tests: if a test pauses longer than 180 seconds between bursts of activity, the pool drains on its own and memory snaps back, so the server looks healthy. Production never pauses that long, so the problem only shows up there.
The fix
Lower
connection_lifetimefrom3600to300. Connections now close and reopen every 5 minutes while still under load, so the memory they held is freed before it can pile up.Same workload, stock config vs the fix:
The effect is clearest here - each dot is one connection sampled every 20 seconds, age vs memory:
Stock drifts to the top-right (older connections holding more memory); the fix keeps both age and memory small.
Cost
One reconnect per connection every 5 minutes. The graphql server already queries each connection constantly, so this is negligible.
Rollout
Test on one host first with
connection_lifetime: 300and confirm: Postgres memory stays bounded across a full workday, thebbb-graphql-serverlogs show no connection errors, and clientgraphql_client_errorrates are unchanged.Draft - opening for early review.