Skip to content

chore(gql-middleware): log active subscriptions when the concurrent limit is reached - #25909

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v4.0.x-developfrom
ritzalam:gql-mw-log-subscription-limit
Oct 5, 2026
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v4.0.x-developfrom
ritzalam:gql-mw-log-subscription-limit

Conversation

@ritzalam

@ritzalam ritzalam commented Oct 1, 2026

Copy link
Copy Markdown
Member

What does this PR do?

When a browser connection reaches max_connection_concurrent_subscriptions, bbb-graphql-middleware now logs which subscriptions are holding the slots.

On the first rejection per connection it writes one warning with:

  • rejectedOperation: the subscription that was refused
  • activeSubscriptions: how many are active
  • activeSubscriptionsByOperation: the active subscriptions grouped by operation name, highest count first, for example chatMessages=3, IsTyping=2, Users=1

Later rejections on the same connection keep the existing Limit exceeded error line only, so a client that keeps retrying does not flood the log.

The grouping lives in a small internal/subscriptionlimit package with no config dependency, so it has a unit test. The common and writer packages load /usr/share/bbb-graphql-middleware/config.yml at init and cannot be tested without it.

Closes Issue(s)

None.

Motivation

On a 4.0.0-rc.3 production server, a moderator's client hit the 150-subscription limit about 88 minutes into a session. From then on the server refused every new subscription: public chat, private chats, cameras and raise-hand stopped loading until the user reloaded.

The only server-side trace was the repeated line Limit exceeded: Maximum 150 concurrent subscriptions allowed. It says nothing about what had accumulated. The connection never reconnected, so whatever filled the 150 slots built up on one connection.

We could not reproduce it. A lab session with a moderator, 45 participants, camera, screenshare, two breakout rooms and 45 private chats opened, messaged and answered peaked at 31 active subscriptions. Reading the client code did not find a subscription that stays open either. Without knowing which operations were active, the cause can't be identified, and raising the limit would only delay the failure.

This change makes the next occurrence on any server diagnosable from the log.

How to test

  1. Lower the limit in /etc/bigbluebutton/bbb-graphql-middleware.yml:
    server:
      max_connection_concurrent_subscriptions: 20
  2. Restart: systemctl restart bbb-graphql-middleware.
  3. Join a meeting as moderator. The client opens about 30 subscriptions at join, so the limit is reached straight away.
  4. Check the log:
    journalctl -u bbb-graphql-middleware | grep 'Concurrent subscription limit reached'
    
    Expect exactly one line for the connection, with the three fields above. The existing Limit exceeded lines continue for each rejection.
  5. Unit test: cd bbb-graphql-middleware && go test ./internal/subscriptionlimit/

More

  • go build ./... and the new test pass. go vet reports two findings in writer.go (a non-constant format string in sendErrorMessage, a discarded context.WithTimeout cancel); both predate this change and are left alone.
  • I have not run the patched middleware on a server yet. Steps 1–4 above are the check I would expect before merge.
  • Added/updated documentation

🤖 Generated with Claude Code

…imit is reached

When a connection reaches max_connection_concurrent_subscriptions, the
middleware rejects each new subscription with "Limit exceeded: Maximum N
concurrent subscriptions allowed." The log line says nothing about what is
holding the slots, so a client that accumulates subscriptions cannot be
diagnosed after the fact.

On the first rejection per connection, log one warning with the rejected
operation, the active count and the active subscriptions grouped by
operation name, highest count first. Later rejections on the same
connection keep the existing error line only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c423b586-2ee7-4e88-9dc6-9723424cad24

📥 Commits

Reviewing files that changed from the base of the PR and between b494e1f and 8453987.

📒 Files selected for processing (4)
  • bbb-graphql-middleware/internal/common/types.go
  • bbb-graphql-middleware/internal/hasura/conn/writer/writer.go
  • bbb-graphql-middleware/internal/subscriptionlimit/summary.go
  • bbb-graphql-middleware/internal/subscriptionlimit/summary_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The change adds SummarizeByOperation to group active subscriptions by operation name and tests its formatting and ordering. When the active subscription count reaches the configured maximum, the writer logs the rejected operation and grouped active subscriptions once per browser connection. The existing rejection response remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 84539

The change adds once-per-connection subscription-limit diagnostics without changing limit enforcement. No merge-blocking issue is identified; merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 84539

The change preserves subscription limits and connection isolation. Its main residual risk is oversized diagnostic output: logging only once per connection limits frequency, but does not bound the combined size of operation names.

Retained concerns

  • Low · security · inferred: The new warning aggregates stored browser-controlled operation names without an aggregate byte limit. A connection reaching its quota can therefore cause additional formatting allocations and a large event in the service's logging sink. The approximately 10 MB WebSocket message limit and once-per-connection guard constrain individual input and frequency, but not the combined event size. Existing arbitrary-name logging is counterevidence against a new logging primitive; batch serialization is the incremental exposure. Material impact depends on configured controls and available resource headroom.
Security review details

Security Blast Radius

  • inferred — The incremental exposure is service-process allocation and logging pressure from one connection's diagnostic event. The inspected path reads only that connection's map and introduces no cross-connection data access or additional client privileges. Consequences for external collectors depend on deployment settings that were unavailable.

Security Findings and Attack Paths

  • inferred — A client able to reach the existing quota branch can supply a large rejected operation name and trigger serialization of stored names. Repeating the warning requires a new browser connection. Existing error paths already log individual operation names, but this PR additionally combines stored values into one event; no aggregate byte cap is present in the changed path.

Trust Boundaries and Controls

  • observed — Existing controls include session authorization, a configured per-connection request rate limiter, the concurrent quota, and a WebSocket message-size limit. The new atomic guard restricts warning attempts, and JSON serialization counters direct newline-based log forging. These controls do not establish an aggregate diagnostic byte budget.

Hardening Proposals

  • proposed — Consider a diagnostic-only byte budget for individual names and the combined event, with explicit truncation metadata. This would contain logging and serialization costs without changing subscription acceptance or rejection semantics.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: logging active subscriptions when the concurrent subscription limit is reached.
Description check ✅ Passed The description directly explains the logging behavior, warning contents, per-connection logging limit, motivation, testing steps, and known validation status.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

⏳ Automated tests are running...

@ramonlsouza
ramonlsouza merged commit ee83789 into bigbluebutton:v4.0.x-develop Oct 5, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants