Skip to content

[3.0 backport] fix(bbb-web): race on concurrent join leaves one user at the error screen (#26322) - #26397

Merged
antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
antobinary:fix-bbb-web-concurrent-join-lost-registration-30
Nov 10, 2026
Merged

antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
antobinary:fix-bbb-web-concurrent-join-lost-registration-30

Conversation

@antobinary

Copy link
Copy Markdown
Member

What does this PR do?

3.0 port of #26322. When users join a new meeting at the same moment, one of them sometimes lands on "Ops, something went wrong" (code 500), because bbb-web dropped their registration before it reached akka-apps. v3.0.x-develop has the same code as 4.0 had (Meeting.java:221, MeetingService.java:1527), so the three commits apply as straight cherry-picks (-x, patch-ids equal to the originals).

  1. test: MeetingUserCustomDataTest in bbb-common-web. Eight threads per fresh Meeting call addUserCustomData together, the way concurrent join requests do, over 2000 meetings; every user's data must still be there. It fails on the current code.
  2. fix: Meeting.userCustomData becomes a ConcurrentHashMap, like users and registeredUsers next to it. It was a plain HashMap written by several request threads: two first puts into a new meeting's map could each allocate its table, and the entry in the table that lost was gone. join then read null back as the user's metadata, BbbWebApiGWApp.registerUser threw a NullPointerException on it, and the user's RegisterUserReqMsg was never published.
  3. fix: MeetingService logs exceptions thrown inside the tasks it runs on runExec. Before, the try/catch that logs "Handling unexpected exception" only covered handing the task over, so an exception inside it went to stderr (bbb-web's journal) and the message was dropped with nothing in bbb-web.log. That is why the lost registrations left no trace in the log.

Keys and values of userCustomData are never null (externUserID falls back to the internal user ID and join always creates the data map), so the switch to ConcurrentHashMap changes no behaviour besides thread safety.

Closes Issue(s)

Port of #26322, which closed #26318. Relates to #26028.

Motivation

The Playwright stress test Stress › Joining users at the same time › Join 2 users (mod and attendee) fails from time to time on 3.0 as well, and real users joining a class that starts at a fixed time can hit the same error screen. On 4.0 every failure came with a NullPointerException at BbbWebApiGWApp.registerUser(BbbWebApiGWApp.scala:330) in bbb-web's journal and no RegisterUserReqMsg for that user on to-akka-apps-redis-channel; the 3.0 code at those lines is identical.

How to test

Unit test, in bbb-common-web (after sbt publishLocal in bbb-common-message):

sbt "testOnly org.bigbluebutton.api.domain.MeetingUserCustomDataTest"

Note for 3.0: Test/compile of bbb-common-web fails on v3.0.x-develop before this PR too, because UnitSpec imports the pre-3.2 ScalaTest aliases (org.scalatest.FlatSpec, org.scalatest.Matchers) while project/Dependencies.scala supplies ScalaTest 3.2.11, and RecMetaXmlHelperTests no longer matches RecMetaXmlHelper. 4.0 repaired that in #25786 (UnitSpec on the 3.2 package layout, -oD reporter, the stale test excluded in build.sbt). The numbers below were measured with that repair applied locally to the test tree only; it is not part of this PR.

Code MeetingUserCustomDataTest Whole bbb-common-web suite
before the fix (commit 1 only) FAIL: 5040 of 16000 users lost their custom data 8 passed, 1 failed (this test)
with this PR PASS 9 passed

sbt compile of bbb-common-web on the branch as pushed (no test-tree repair): success.

On a server: let two browsers open the moderator's and a viewer's join links of a new meeting at the same moment, round after round, without ending the earlier meetings, and watch journalctl -u bbb-web | grep -A1 "Exception in thread". On 4.0.1 that went from 4 error screens in 113 rounds (one NullPointerException each) to 0 in 150 with the same three commits (#26322). Scripted API joins do not reproduce the race (they do not arrive close enough together), so it needs real browsers or the unit test.

More

…data

When users of a new meeting join at the same moment, their join requests
write their custom data to the meeting from several threads at once.
Meeting.userCustomData is a plain HashMap, so an entry can be lost; join
then reads null back for that user, and the MeetingService task that
publishes the user's RegisterUserReqMsg to akka-apps throws a
NullPointerException in BbbWebApiGWApp.registerUser. akka-apps never
learns the user, the client's first GraphQL REST call is refused
("x-hasura-role" not found in session variables) and the user lands on
the error screen. The Playwright stress test "Join 2 users (mod and
attendee)" fails this way from time to time.

The test starts eight threads per fresh meeting, held in a busy spin
until all of them run so that they reach the meeting together, and checks
that every user's data is still there, over 2000 meetings. On the current
Meeting it fails at once (8245 of 16000 users lost their data in one
run); with userCustomData as a ConcurrentHashMap it passes.

(cherry picked from commit 3c819cb)
Users joining a meeting at the same moment write their custom data to
Meeting.userCustomData from several request threads at once. The map was
a plain HashMap: two first puts into a new meeting's map can each
allocate its table, and the entry written into the table that loses is
gone. join then read null back as the user's metadata,
BbbWebApiGWApp.registerUser threw a NullPointerException on it, and the
user's RegisterUserReqMsg never reached akka-apps. akka-apps did not know
the session, so Hasura refused the client's first GraphQL request
("x-hasura-role" not found in session variables) and the user got
"Ops, something went wrong".

userCustomData is a ConcurrentHashMap now, like users and
registeredUsers next to it. Its keys and values are never null:
externUserID falls back to the internal user ID and join always creates
the data map.

MeetingUserCustomDataTest passes with it (it failed before: 8245 of
16000 users lost their data), as do the other 74 bbb-common-web tests.
On a 4.0.1 server, two browsers joining a new meeting at the same moment
failed in 4 of 113 rounds before and in none of 150 rounds after, with no
NullPointerException in bbb-web's journal.

(cherry picked from commit d6e30cf)
MeetingService.processMessage hands every message to runExec as a task.
The try/catch that logs "Handling unexpected exception" only covers that
hand-over, so an exception inside the task ended runExec's thread with a
trace on stderr (bbb-web's journal) and nothing in bbb-web.log, and the
message it was handling was dropped without a trace. That is how users
whose registration was lost to the userCustomData race went unnoticed.

The task now runs inside a try/catch that logs the exception with the
message type, and runExec keeps its thread.

(cherry picked from commit de4a172)
@antobinary antobinary added this to the Release 3.0 milestone Nov 4, 2026
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Meeting.userCustomData now uses a ConcurrentHashMap. A regression test checks concurrent writes and readbacks for eight users across 2,000 meetings. MeetingService.processMessage now catches and logs exceptions thrown by message tasks, including the message class name.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: tainan404, paultrudel

Merge Risk: Minimal · up to e905a

The change addresses concurrent custom-data writes and improves message-task error logging. No actionable merge-blocking risk is established; the reported pre-existing test-compilation problems remain a validation limitation.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the change: a 3.0 backport of a fix for a race on concurrent joins that leaves one user at the error screen. The changeset matches it: a ConcurrentHashMap for Meeting.userCustomData, l…
Description check Passed The description states the purpose, the three changes, the test command, the 3.0 build caveats, and the validation numbers. It matches the changeset closely. It is not off-topic and it gives clear det…
Linked Issues check Passed The only linked issue is #26318. It is marked as closed and as historical context only, and it is marked as a direct link. Closed issues supply background only, so no active directly linked target rem…
Out of Scope Changes check Passed The whole-PR diff (merge base 9e8622f to head e905a23) has three changes, and each one relates to the root cause in #26318. (1) Meeting.java: userCustomData is initialized as a ConcurrentHashMap ins…
Full details: Title check

Explanation

The title names the change: a 3.0 backport of a fix for a race on concurrent joins that leaves one user at the error screen. The changeset matches it: a ConcurrentHashMap for Meeting.userCustomData, logging of exceptions in MeetingService runExec tasks, and a concurrency test in MeetingUserCustomDataTest. The title is specific and accurate, though it does not mention the logging change.

Full details: Description check

Explanation

The description states the purpose, the three changes, the test command, the 3.0 build caveats, and the validation numbers. It matches the changeset closely. It is not off-topic and it gives clear detail on each file touched.

Full details: Linked Issues check

Explanation

The only linked issue is #26318. It is marked as closed and as historical context only, and it is marked as a direct link. Closed issues supply background only, so no active directly linked target remains. No linked-issue coding requirements apply to this pull request. The pull request still implements the root cause described in #26318 (plain HashMap for Meeting.userCustomData, and exceptions in runExec tasks that were not logged). This is context only and does not change the result.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base 9e8622f to head e905a23) has three changes, and each one relates to the root cause in #26318. (1) Meeting.java: userCustomData is initialized as a ConcurrentHashMap instead of a HashMap. This removes the lost-entry race that returned null to join and registerUser. (2) MeetingService.java: the task passed to runExec is wrapped in a lambda that catches and logs exceptions with the message class name. This matches the suggested fix in #26318 so that dropped messages appear in bbb-web.log. (3) MeetingUserCustomDataTest.scala: a new concurrency test that supports change (1). It is a test only and changes no production behaviour. No unrelated change was found in the summary. The pull request does not change the two other HashMap fields, and the PR description states that this is intentional. This is not an out-of-scope change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 15f10d3c-6365-404d-af28-99e5374ecca2
Commits

Reviewing files that changed from the base of the PR and between 9e8622f and e905a23.

Files selected for processing: 3
  • bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java
  • bbb-common-web/src/main/java/org/bigbluebutton/api/domain/Meeting.java
  • bbb-common-web/src/test/scala/org/bigbluebutton/api/domain/MeetingUserCustomDataTest.scala

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

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🚨 Automated tests failed

@antobinary
antobinary merged commit 5e6b9b0 into bigbluebutton:v3.0.x-develop Nov 10, 2026
25 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.

1 participant