Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Persisted subscription in subscription resumption mode are not removed when a new subscription with keepSubscriptions=false comes in #37739

Closed
dvdm-qorvo opened this issue Feb 24, 2025 · 1 comment · Fixed by #37741
Labels
bug Something isn't working needs triage

Comments

@dvdm-qorvo
Copy link
Contributor

dvdm-qorvo commented Feb 24, 2025

The specification is stating:

Image

This means that active (existing) subscriptions needs to be terminated when keepSubscriptions flag is set to FALSE → This is implemented and works as expected. (see below code snippet of OnReadInitialRequest function of src/app/InteractionModelEngine.cpp). It checks the flag keepExistingSubscriptions and it will iterate over the active readHandlers, if it finds an active subscription, it will close and release the subscription and corresponding readHandler. This frees the resource for a new subscription being set up.

    if (!keepExistingSubscriptions)
    {
        //
        // Walk through all existing subscriptions and shut down those whose subscriber matches
        // that which just came in.
        //
        mReadHandlers.ForEachActiveObject([apExchangeContext](ReadHandler * handler) {
            if (handler->IsFromSubscriber(*apExchangeContext))
            {
                ChipLogProgress(InteractionModel,
                                "Deleting previous active subscription from NodeId: " ChipLogFormatX64 ", FabricIndex: %u",
                                ChipLogValueX64(apExchangeContext->GetSessionHandle()->AsSecureSession()->GetPeerNodeId()),
                                apExchangeContext->GetSessionHandle()->GetFabricIndex());
                handler->Close();
            }

            return Loop::Continue;
        });
  }

But the specification is also mentioning it shall terminate any pending subscriptions. A subscription that is in a subscription resumption state can be seen as a pending subscription.
→ This implementation is missing in the Matter SDK. The persisted subscription will be kept in subscription resumption state and the stack keeps trying to resume this subscription, although the controller requested to terminate it (keepSubscription flag is set to false). So this subscription needs to be removed as well.

Reproduction steps

Performed the test with QPG light switch device (enabled persisted subscriptions and subcription resumption timeout)

  1. Commission the device with chiptool and setup a subscription on switch events. (keepSubscription = false, is-urgent=true)
  2. Check that the reports are coming in as expected when the switch device is triggered
  3. Move the switch device out-or-range
  4. Trigger the switch, so the report can't be sent out after retries, and the subscription goes into subscription resumption mode
  5. Bring the device back in range while the subscription resumption is still ongoing.
  6. Setup a subscription again with keepSubscriptions = False
  7. Check that the reports are coming in as expected when the switch device is triggered (with the new subscription)
  8. After some time, the subscription resumption timer will be fired and it will try to resume the old subscription although, keepSubscription was set to false.

Solution should be that when the keepSubscription flag is set to false, the subscription resumption shall be terminated and the relevant persisted subscription shall be removed from persisted storage.

Bug prevalence

Always

GitHub hash of the SDK that was being used

master

Platform

other

Platform Version(s)

No response

Anything else?

Linked Issue Report: #36081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
2 participants