You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[3.0 backport] fix(bbb-web): race on concurrent join leaves one user at the error screen (#26322) - #26397
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).
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.
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.
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.
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):
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.
…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)
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.
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: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
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 checks: 4 passed
Check name
Status
Explanation
Title check
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
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
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
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-develophas 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).MeetingUserCustomDataTestin bbb-common-web. Eight threads per freshMeetingcalladdUserCustomDatatogether, the way concurrentjoinrequests do, over 2000 meetings; every user's data must still be there. It fails on the current code.Meeting.userCustomDatabecomes aConcurrentHashMap, likeusersandregisteredUsersnext to it. It was a plainHashMapwritten by several request threads: two firstputs into a new meeting's map could each allocate its table, and the entry in the table that lost was gone.jointhen readnullback as the user's metadata,BbbWebApiGWApp.registerUserthrew aNullPointerExceptionon it, and the user'sRegisterUserReqMsgwas never published.MeetingServicelogs exceptions thrown inside the tasks it runs onrunExec. Before, thetry/catchthat 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 inbbb-web.log. That is why the lost registrations left no trace in the log.Keys and values of
userCustomDataare nevernull(externUserIDfalls back to the internal user ID andjoinalways creates the data map), so the switch toConcurrentHashMapchanges 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 aNullPointerExceptionatBbbWebApiGWApp.registerUser(BbbWebApiGWApp.scala:330)in bbb-web's journal and noRegisterUserReqMsgfor that user onto-akka-apps-redis-channel; the 3.0 code at those lines is identical.How to test
Unit test, in
bbb-common-web(aftersbt publishLocalinbbb-common-message):Note for 3.0:
Test/compileof bbb-common-web fails onv3.0.x-developbefore this PR too, becauseUnitSpecimports the pre-3.2 ScalaTest aliases (org.scalatest.FlatSpec,org.scalatest.Matchers) whileproject/Dependencies.scalasupplies ScalaTest 3.2.11, andRecMetaXmlHelperTestsno longer matchesRecMetaXmlHelper. 4.0 repaired that in #25786 (UnitSpecon the 3.2 package layout,-oDreporter, the stale test excluded inbuild.sbt). The numbers below were measured with that repair applied locally to the test tree only; it is not part of this PR.MeetingUserCustomDataTestsbt compileof 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 (oneNullPointerExceptioneach) 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
Meetingmaps,guestUsersWithPositionInWaitingLineandusersWithGuestLobbyMessages, are plainHashMaps too. They are left alone here, as in [4.0] fix(bbb-web): fixes race condition on user join leaving one user stuck at Oops screen #26322: nothing showed them written by several threads at once.