Skip to content

RDKEMW-21222: Implement connection-level and session-level cleanup mechanisms#949

Merged
kvfasil merged 10 commits into
3.3.rcfrom
fix/RDKEMW-21222
Jul 14, 2026
Merged

RDKEMW-21222: Implement connection-level and session-level cleanup mechanisms#949
kvfasil merged 10 commits into
3.3.rcfrom
fix/RDKEMW-21222

Conversation

@kvfasil

@kvfasil kvfasil commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What

What does this PR add or remove?

Why

Why are these changes needed?

How

How do these changes achieve the goal?

Test

How has this been tested? How can a reviewer test it?

Checklist

  • I have self-reviewed this PR
  • I have added tests that prove the feature works or the fix is effective

kvfasil added 3 commits July 8, 2026 13:29
…chanisms

- Add CleanupType enum with Connection(cid) and Session(session_id) variants
- Update BrokerCleaner with cleanup_connection() and cleanup_session() methods
- Add cleanup_for_connection() for WebSocket disconnect (cleans only that connection)
- Add cleanup_for_session() for app unload (cleans ALL subscriptions for session)
- Update subscription_map to use cid as key when available via get_subscription_key()
- Wire session cleanup in end_session() in delegated_launcher_handler
- Remove unused cleanup_for_app() and UnloadSession command
- Add unit tests for cleanup functionality
…ure mode

- Remove redundant AppEvents::remove_session(session_id) call from disconnect handler
- Add comprehensive unit test test_cleanup_by_connection_id_shared_session_multi_connection
  to verify multi-connection shared session scenario and prevent regression.

This prevents correctness bugs in secure connection mode where multiple clients
share the same logical session.
…ion requests

- Log 'Sending Thunder register for <plugin>.<event>' when subscribing to Thunder events
- Log 'Sending Thunder unregister for <plugin>.<event>' when unsubscribing from Thunder events
- These logs enable runtime monitoring of subscription lifecycle for debugging memory leaks
- Example: 'Sending Thunder unregister for org.rdk.TextToSpeech.onnetworkerror'
Copilot AI review requested due to automatic review settings July 10, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces distinct cleanup paths for WebSocket-connection disconnects vs app-session termination, aiming to prevent over-cleaning in secure-mode scenarios where multiple connections share a session.

Changes:

  • Add connection-level vs session-level cleanup semantics via a new CleanupType and new cleanup_for_connection / cleanup_for_session APIs.
  • Update disconnect handling to clean listeners/subscriptions by connection id (cid) instead of session id.
  • Extend/adjust tests to validate correct listener cleanup in shared-session multi-connection scenarios.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
core/main/src/service/apps/delegated_launcher_handler.rs Adds session-level endpoint cleanup on app session end.
core/main/src/service/apps/app_events.rs Adds a regression test ensuring cid-based cleanup doesn’t remove other connections in the same session.
core/main/src/firebolt/firebolt_gateway.rs Switches disconnect cleanup to cid-based listener + broker subscription cleanup.
core/main/src/broker/websocket_broker.rs Updates cleaner channel to use CleanupType for cleanup signaling.
core/main/src/broker/thunder_broker.rs Implements cid-based and session-based broker subscription cleanup logic; adjusts subscription keying behavior.
core/main/src/broker/endpoint_broker.rs Introduces CleanupType, adds connection/session cleanup APIs, and updates tests accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/broker/thunder_broker.rs
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Comment thread core/main/src/broker/endpoint_broker.rs Dismissed
Comment thread core/main/src/service/apps/delegated_launcher_handler.rs Dismissed
Copilot AI review requested due to automatic review settings July 10, 2026 00:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread core/main/src/broker/thunder_broker.rs
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Comment thread core/main/src/service/apps/app_events.rs
- Remove DeviceEvent::Cleanup enum variant from device_events.rs
- Remove Cleanup handling from thunder_events.rs processor
- Remove Cleanup handling from thunder_event_processor.rs
- Remove cleanup dispatch from firebolt_gateway.rs
- Remove related unit tests (test_cleanup_event_request_payload_roundtrip, test_cleanup_event_contract)
- Remove unused 'log::info' import

Note: Connection-level cleanup via cleanup_for_connection() remains and handles
all necessary broker-layer subscription cleanup. This is sufficient for proper
system cleanup without requiring the extension layer cleanup.
Copilot AI review requested due to automatic review settings July 10, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

core/main/src/broker/service_broker.rs:26

  • trace! is imported from jsonrpsee::tracing, while the rest of this broker uses the ripple_sdk::log facade (error!/info!). This mixes two logging backends and can cause the new trace log to be dropped or configured differently than other broker logs. Prefer using ripple_sdk::log::trace for consistency across the codebase.
use crate::state::platform_state::PlatformState;
use jsonrpsee::tracing::trace;
use ripple_sdk::{
    api::{gateway::rpc_gateway_api::JsonRpcApiError, observability::log_signal::LogSignal},
    log::{error, info},
    service::service_message::{Id, ServiceMessage},

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/broker/thunder_broker.rs Dismissed
Use cid (connection_id) as storage key with fallback to session_id,
matching Thunder broker pattern. This ensures cleanup_for_connection(cid)
can properly close brokers when WebSocket disconnects.
Copilot AI review requested due to automatic review settings July 10, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/firebolt/firebolt_gateway.rs
Comment thread core/main/src/broker/service_broker.rs Outdated
Comment thread device/thunder_ripple_sdk/src/processors/thunder_events.rs
Copilot AI review requested due to automatic review settings July 10, 2026 18:39
Only re-insert Vec into subscription_map if it's non-empty after
removing matching subscription. This prevents map bloat from accumulating
empty entries when requests with listen=false remove the last subscription
for a key, avoiding unnecessary memory usage and cleanup iterations.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

core/main/src/broker/service_broker.rs:26

  • ServiceBroker imports trace from jsonrpsee::tracing, but the rest of this crate appears to consistently use the ripple_sdk::log macros (e.g., many files import log::{..., trace}). Mixing logging frameworks can lead to inconsistent filtering/formatting. Prefer using ripple_sdk::log::trace here as well.
use jsonrpsee::tracing::trace;
use ripple_sdk::{
    api::{gateway::rpc_gateway_api::JsonRpcApiError, observability::log_signal::LogSignal},
    log::{error, info},
    service::service_message::{Id, ServiceMessage},

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/service/apps/app_events.rs
Copilot AI review requested due to automatic review settings July 10, 2026 19:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/service/apps/delegated_launcher_handler.rs
Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/service/apps/app_events.rs
Comment thread device/thunder_ripple_sdk/src/processors/thunder_events.rs
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Comment thread core/main/src/broker/thunder_broker.rs Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread core/main/src/firebolt/firebolt_gateway.rs
Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/service/apps/app_events.rs
Copilot AI review requested due to automatic review settings July 13, 2026 20:35
@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
core.main.src.firebolt 13%
core.sdk.src.processor 9%
core.main.src.processor.storage 0%
core.main.src.service.apps 33%
core.main.src.state.cap 42%
core.sdk.src.service.mock_app_gw.appgw 0%
core.sdk.src.api.gateway 69%
core.main.src.bootstrap.extn 0%
core.main.src.bootstrap 0%
core.sdk.src.api.distributor 29%
core.main.src 0%
core.sdk.src.extn 76%
core.tdk.src.utils 0%
device.thunder_ripple_sdk.src.processors.events 0%
core.main.src.firebolt.handlers 12%
device.mock_device.src 56%
core.main.src.service.ripple_service 9%
core.main.src.broker.rules 78%
core.sdk.src.api 44%
core.sdk.src.api.observability 57%
core.main.src.state 36%
core.sdk.src.service.mock_app_gw 0%
core.main.src.broker.thunder 37%
core.sdk.src.extn.client 81%
core.tdk.src.gateway 100%
core.sdk.src.api.manifest 74%
device.thunder_ripple_sdk.src.bootstrap 0%
device.thunder_ripple_sdk.src.processors 19%
core.main.src.bootstrap.manifest 0%
core.main.src.processor 0%
core.sdk.src.api.firebolt 85%
core.main.src.broker 69%
core.main.src.broker.test 90%
core.sdk.src.extn.ffi 0%
core.sdk.src.api.device 75%
core.sdk.src.utils 58%
core.main.src.service.extn 25%
device.thunder_ripple_sdk.src.client 61%
core.main.src.service 32%
core.sdk.src.framework 64%
core.sdk.src.manifest 0%
device.thunder_ripple_sdk.src 13%
core.main.src.utils 28%
device.thunder_ripple_sdk.src.events 43%
core.sdk.src.service 65%
Summary 50% (21971 / 44183)

Minimum allowed line rate is 48%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread core/main/src/broker/websocket_broker.rs
Comment thread core/main/src/firebolt/firebolt_gateway.rs
@Manivannan1802
Manivannan1802 self-requested a review July 14, 2026 13:09
@kvfasil
kvfasil merged commit 8590ab6 into 3.3.rc Jul 14, 2026
9 checks passed
@kvfasil
kvfasil deleted the fix/RDKEMW-21222 branch July 14, 2026 13:14
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants