GeezerVison is showing github.com — fix(calls): keep a group call known while anyone is in it, let ending win over a late registration (#1628, #1630) by Storypapst · Pull Request #1641 · OpenResilienceInitiative/ORISO-UserService
Conversation
What this fixes
The call message in an encrypted conversation asks the server whether a call is still running. Three things were still wrong after the call-tracking fix (#1625):
- The person who started the call goes offline while others keep talking. Only their browser kept the call "known" to the server. About 10 minutes later the server said "unknown", and the message switched to "ended" with no Join button, although people were still in the call.
- An end that arrives before the registration. The browser gives up on the registration after 30 seconds. If the call ended in that window, the end found nothing to end and the late registration stayed "running".
- The server held a database connection open while it waited for Matrix. Under load this can exhaust the connection pool.
With this PR:
- The server itself looks, at most once a minute per call, at who is still in the call (the call memberships in the call room, which are readable even in encrypted calls). While any member of the conversation is still in it, the call stays "running", whoever started it. When everybody has left, the call is marked ended within about a minute. If the server cannot tell (Matrix unreachable, unknown format), it changes nothing.
- An end that arrives first leaves a marker, and the late registration of the same call is refused. The call stays ended.
- Every Matrix lookup now happens before the short database write. No transaction is open while Matrix is called.
No Frontend change is needed: the existing call message polling and the creator's existing registration are enough.
Merge after #1638. This branch is built on #1638 (1:1 session calls), because both change the same lines in the registration code. Until #1638 is merged, this PR's diff also shows #1638's commits.
Refs #1628
Refs #1630
How to test (after deployment to Dev)
Verified: local only (unit tests, and an integration test on MariaDB 10.11 in Testcontainers). Not yet verified on Dev.
For developers: change details and test evidence (skip if you only need the status):
#1630 (a) No transaction around Matrix calls
- MatrixCallObservationService.register/end and MatrixCallStateService.read are no longer @Transactional.
Order: Matrix lookups -> one short TransactionTemplate write (lock + read + write) -> notifications
(each notification already runs in its own transaction). Binding read path keeps a short read-only
TransactionTemplate around the lazy device map.
- Guard: MatrixCallObservationServiceTest records every Matrix/notification call made while the test
transaction manager has a transaction open (mutation-checked: a Matrix call moved inside the write
makes registrationCallsMatrixAndNotifiesOutsideAnyTransaction fail). MariaDB IT asserts the same with
TransactionSynchronizationManager.isActualTransactionActive().
#1630 (b) Race test on MariaDB
- MatrixCallObservationMariaDbIT.parallelFirstRegistrationsLeaveOneRowAndOneInvitation: two first
registrations meet inside their write transactions (CyclicBarrier). Observed: MariaDB 1213 deadlock
for the loser -> PessimisticLockingFailureException (controller answers 409), exactly one row, and the
loser's retry renews without a second invitation.
#1628 (2) End wins over a late registration
- /observations/end with no row: a current member of the conversation writes a tombstone row
(origin END_TOMBSTONE, media_room_id NULL, ended_at = expires_at = now). register rejects any ended row,
so the same creator's late registration gets 404. A tombstone written by somebody other than the
registering creator is deleted and replaced by the real registration, so a member cannot suppress
another person's call. Unique-key or deadlock collision between tombstone and registration: end retries
once and then ends the registered row.
#1628 (1) Liveness from MatrixRTC membership
- readState: when lastSeenAt and livenessCheckedAt are both >= 60 s old, the server reads the media room
state (MatrixSynapseService.getCallRoomState, as the creator if still joined, else another joined
conversation member) and parses org.matrix.msc3401.call.member with the existing
MatrixRtcMembershipEvent parser. Only senders who are current conversation members count.
- someone active (non-empty, not expired) -> keepAlive: lease = now + 10 min, also after it ran out
- every parsed membership departed/expired and registered >= 2 min ago -> finishAt(last presence),
call.ended notifications to members (deduplicated per room+call)
- no parsable membership, Matrix unavailable, nobody to read as -> no change (only livenessCheckedAt)
- Known limit: a browser that crashes without its delayed leave event keeps its membership until the
membership expires (Element Call default 4 h), same as the existing binding path.
- No Frontend change: non-creators cannot renew through POST /observations (it checks the media-room
creator), and with server-side liveness they do not need to.
Schema: Liquibase 20261113_call_observation_lease_1628
matrix_call_observation.media_room_id -> NULL allowed; + liveness_checked_at BIGINT NULL.
Rollback deletes tombstones (media_room_id IS NULL), restores NOT NULL, drops the column.
uk_call_observation_media_room unchanged (NULLs do not collide on MariaDB).
MatrixCallObservationIsolationTest: allows the service's own private nested types (records/enums).
#1630 (c) Dev check, 13 Nov 2026 00:49 UTC, read-only SELECT on Dev MariaDB:
matrix_call_observation 0 rows, matrix_call_binding 0 rows (observation changeset applied 2026-11-11).
Nothing stuck on Dev, but also no observed call there to inspect. Staging: no DB access set up; not checked.
#1630 (d) 1:1 session calls: #1638 (server) + Frontend#2238. Internal group chats: already on dev via #1625.
Tests (JDK 21):
./mvnw -B test -Dtest='MatrixCallObservation*Test,MatrixCallStateControllerTest,CallObservationRetentionServiceTest' -Dsurefire.failIfNoSpecifiedTests=false
./mvnw -B test -Dtest=MatrixCallObservationMariaDbIT -Dsurefire.failIfNoSpecifiedTests=false (Docker)
./mvnw -B test (full unit suite) -> 8944 run, 0 failures, 0 errors, BUILD SUCCESS; spotless:check clean.
Targeted: 67 run, 0 failures. MariaDB IT: 3 run, 0 failures.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
… win (#1628, #1630)
- No database transaction is open while Matrix is called: register, end and
the state read do Matrix lookups first, then one short write transaction,
then notifications (#1630 a).
- MariaDB race test for parallel first registrations (#1630 b).
- An end that arrives before the registration leaves a tombstone; the late
registration of the same call is rejected (#1628).
- At most once a minute per call, the server reads the MatrixRTC memberships
of the media room: someone from the conversation still in the call extends
the lease; everybody gone ends the call. Inconclusive answers change
nothing (#1628).
- Liquibase: media_room_id nullable, liveness_checked_at.
Refs #1628
Refs #1630
Co-Authored-By: Claude Opus 5.5 <[email protected]>
coderabbitai
Bot
commented
Nov 13, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Warning
Review limit reached
Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.
Next included review available in 55 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available. Your 93 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
Learn how review limits work.
Review configuration:
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between d6be1fa and 7886b77.
Files selected for processing: 21
-
src/main/java/de/caritas/cob/userservice/api/adapters/matrix/MatrixSynapseService.java
src/main/java/de/caritas/cob/userservice/api/model/MatrixCallObservation.java
src/main/java/de/caritas/cob/userservice/api/model/MatrixCallObservationEnd.java
src/main/java/de/caritas/cob/userservice/api/port/out/MatrixCallObservationEndRepository.java
src/main/java/de/caritas/cob/userservice/api/service/matrix/MatrixCallObservationService.java
src/main/java/de/caritas/cob/userservice/api/service/matrix/MatrixCallStateService.java
src/main/java/de/caritas/cob/userservice/api/service/matrix/MatrixRtcMembershipEvent.java
src/main/java/de/caritas/cob/userservice/api/workflow/callobservationretention/service/CallObservationRetentionService.java
src/main/resources/db/changelog/changeset/20261112_call_observation_session_2237/changeSet.xml
src/main/resources/db/changelog/changeset/20261113_call_observation_chat_nullable_2237/changeSet.xml
src/main/resources/db/changelog/changeset/20261113_call_observation_end_1628/changeSet.xml
src/main/resources/db/changelog/changeset/20261113_call_observation_lease_1628/changeSet.xml
src/main/resources/db/changelog/userservice-master.xml
src/test/java/de/caritas/cob/userservice/api/CallObservationEndMigrationMariaDbIT.java
src/test/java/de/caritas/cob/userservice/api/CallObservationSessionMigrationMariaDbIT.java
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/MatrixCallStateControllerTest.java
src/test/java/de/caritas/cob/userservice/api/service/matrix/MatrixCallObservationIsolationTest.java
src/test/java/de/caritas/cob/userservice/api/service/matrix/MatrixCallObservationMariaDbIT.java
src/test/java/de/caritas/cob/userservice/api/service/matrix/MatrixCallObservationServiceTest.java
src/test/java/de/caritas/cob/userservice/api/service/matrix/RecordingTransactionManager.java
src/test/java/de/caritas/cob/userservice/api/workflow/callobservationretention/service/CallObservationRetentionServiceTest.java
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 13, 2026
Storypapst
added a commit
that referenced
this pull request
Nov 13, 2026
…#2209)
Security review round 1 of US#1642:
- A known ORISO conversation room (session, chat, occurrence, team,
supervisor, support) is never accepted as a call room.
- "Ending wins" (#1641): the caller's end tombstone, or an ended or lapsed
observation of the call, refuses a late binding. Deny-only read.
- Assignment and account are checked again under the session lock.
- An ended or no longer live binding is never renewed; a live exact
binding is confirmed without any Matrix lookup.
- Guest admission requires a live call (MatrixCallBinding.isLive), and a
session call that was never observed ends 10 minutes after its invite
ran out, revoking outstanding seats.
- A race on the uk_call_binding_* keys is a 409, not a 500.
Tests: unit cases for each, controller cases, and a CallShareLinkIT case
for bind -> share link -> knock -> seat -> never-observed end on a real DB.
Refs OpenResilienceInitiative/ORISO-Frontend#2209
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A liveness verdict is discarded when a renewal or another check
committed while Matrix was read, so an older "everybody left" cannot
overtake a newer confirmed presence.
- A call-member event of a conversation participant that this server
cannot parse makes the check inconclusive instead of counting as a
departure.
- The liveness_checked_at column is added in its own changeset with a
MARK_RAN precondition, as the master changelog requires.
Addresses CodeRabbit review on US#1642.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked the call lifecycle change: a group call now stays running while any member is still in it and ends within about a minute after the last one leaves, a late registration can no longer revive an ended call, and Matrix is no longer called inside a database transaction. Merge after #1638, which this branch is built on.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Storypapst
added a commit
that referenced
this pull request
Nov 13, 2026
…check (FE#2209)
- An explicit end by the binding's caller now ends the session call's
binding after the observation end, then revokes guest seats after the
commit, so share links, knocks and seats stop at once.
- The binding reads the call's observation row with a write lock, so an
end that commits meanwhile either refuses the binding or ends it.
- The ORISO-room check counts sessions and team discussions with native
queries, so another Träger's room (or a missing tenant context) never
passes as a dedicated call room.
- Tests: expired retained device seats nobody; the guest admitted before
a never-observed call ends is revoked, removed and its power level
cleared.
- Merges the #1641 CodeRabbit fixes from fix/1628-1630-call-lease.
Addresses CodeRabbit review on US#1642.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approving after #1638 merged; the code is unchanged. A group call stays running while anyone is still in it and ends within about a minute after the last person leaves.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
An end that arrived before the registration was kept as one END_TOMBSTONE row
in matrix_call_observation. The unique key on (source room, call) allowed one
such row, so the creator's own cancellation was dropped when another member
had ended first, and the creator's late registration then went through.
Ends now live in matrix_call_observation_end, one row per (source room, call,
actor). The creator's stored end refuses a late registration (locking read, so
an end being written is waited for); other people's ends are kept but do not
suppress it. A call ended before its registration still reads as ended. The
new changesets create the table (MARK_RAN when it exists), move existing
tombstone rows into it, and make media_room_id required again. Retention also
ages out stored ends.
#2237: the session_id changeset gets an onFail=MARK_RAN precondition. Liquibase
4.27 leaves preconditions out of the checksum (9:135d1aa1... before and after),
so Dev is unaffected. A follow-up changeset applies the chat_id nullability
that a MARK_RAN would skip.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps #1639's group waiting room changeset (20261112, already on dev) ahead of
the #1628/#2237 call observation changesets of this branch, in date order.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep dev's 20261113_communication_stat include ahead of this branch's
20261113 call-observation changesets in userservice-master.xml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
shazia-k
shazia-k approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|