Skip to content

Retry operational CASE setup after responder BUSY#72824

Draft
feasel0 wants to merge 3 commits into
project-chip:masterfrom
feasel0:feature/readattribute-resource-busy-33830
Draft

Retry operational CASE setup after responder BUSY#72824
feasel0 wants to merge 3 commits into
project-chip:masterfrom
feasel0:feature/readattribute-resource-busy-33830

Conversation

@feasel0

@feasel0 feasel0 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The problem

A Python ReadAttribute() first calls GetConnectedDevice() before sending the Interaction Model read. The normal controller path requests only a small operational CASE setup attempt budget, and that budget is decremented as soon as operational discovery/setup begins.

If the responder then sends a Secure Channel BUSY status with a requested wait time, OperationalSessionSetup::OnResponderBusy() records the delay, but OnSessionEstablishmentError() only schedules a retry when mRemainingAttempts > 0. With the attempt budget already exhausted, the stack surfaces CHIP_ERROR_BUSY back to the caller instead of honoring the peer's "wait, then retry" response.

This appears as an intermittent read failure under stress: session/subscription recovery or other operational traffic creates timing pressure, the device responds BUSY, and a plain one-shot read fails while trying to reacquire a CASE session. The next attempt typically succeeds once the device is no longer contended.

There was a TODO comment in ScheduleSessionSetupReattempt() about whether BUSY should restore retry budget, so this issue was clearly contemplated by the original author.

The fix

Update OperationalSessionSetup::OnResponderBusy() so that when a responder BUSY arrives after the normal attempt budget is exhausted, the setup object grants one bounded retry. Because OnResponderBusy() runs before OnSessionEstablishmentError() for the same BUSY, the restored budget allows the existing retry path to schedule the peer-requested wait instead of failing.

The retry is intentionally limited to one extra grant per setup object, tracked by a new mGrantedBusyRetryAfterAttemptExhaustion flag, so this honors the responder's explicit retry request without creating an unbounded retry loop. Larger existing retry budgets are left untouched, and the normal busy-delay handling continues to use the responder-requested delay when scheduling the retry.

Testing

Added TestOperationalSessionSetupBusy.cpp and wired it into src/app/tests/BUILD.gn.

The new unit tests cover:

  • granting one retry when BUSY arrives after the attempt budget is exhausted
  • preserving an existing (larger) resolve retry budget
  • not granting an extra retry when normal retry budget remains
  • granting the BUSY retry only once per setup object, even across multiple BUSY responses

Related issues

Fixes #33830

Co-authored-by: Copilot <copilot@github.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.66%. Comparing base (d9d3108) to head (a92e88c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #72824      +/-   ##
==========================================
+ Coverage   56.62%   56.66%   +0.03%     
==========================================
  Files        1642     1642              
  Lines      113154   113159       +5     
  Branches    13235    13225      -10     
==========================================
+ Hits        64079    64121      +42     
+ Misses      49075    49038      -37     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR #72824: Size comparison from d9d3108 to 3908735

Full report (22 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, nrfconnect, psoc6, qpg, realtek, stm32)
platform target config section d9d3108 3908735 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1099194 1099228 34 0.0
RAM 133418 133418 0 0.0
bl702 lighting-app bl702+eth FLASH 1085744 1085778 34 0.0
RAM 109029 109029 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 882236 882270 34 0.0
RAM 108596 108596 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 777384 777416 32 0.0
RAM 103404 103404 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 790136 790168 32 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 739392 739424 32 0.0
RAM 97612 97612 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 719564 719596 32 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 569670 569702 32 0.0
RAM 205112 205112 0 0.0
lock CC3235SF_LAUNCHXL FLASH 597230 597262 32 0.0
RAM 205272 205272 0 0.0
efr32 lighting-app BRD4187C FLASH 1104716 1104748 32 0.0
RAM 135360 135360 0 0.0
lock-app BRD4187C FLASH 995184 995216 32 0.0
RAM 131292 131292 0 0.0
BRD4338a FLASH 799825 799873 48 0.0
RAM 243432 243432 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 845892 845928 36 0.0
RAM 157923 157923 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1752716 1752764 48 0.0
RAM 215644 215644 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1626564 1626596 32 0.0
RAM 211604 211604 0 0.0
light cy8ckit_062s2_43012 FLASH 1470876 1470908 32 0.0
RAM 197436 197436 0 0.0
lock cy8ckit_062s2_43012 FLASH 1504324 1504372 48 0.0
RAM 225268 225268 0 0.0
qpg lighting-app qpg6200+debug FLASH 843292 843324 32 0.0
RAM 127908 127908 0 0.0
lock-app qpg6200+debug FLASH 783064 783096 32 0.0
RAM 118840 118840 0 0.0
realtek light-switch-app rtl8777g FLASH 689984 690016 32 0.0
RAM 101880 101880 0 0.0
lighting-app rtl8777g FLASH 730320 730352 32 0.0
RAM 102052 102052 0 0.0
stm32 light STM32WB5MM-DK FLASH 478996 479028 32 0.0
RAM 141492 141492 0 0.0

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR #72824: Size comparison from d9d3108 to a92e88c

Full report (33 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
platform target config section d9d3108 a92e88c change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1099194 1099228 34 0.0
RAM 133418 133418 0 0.0
bl702 lighting-app bl702+eth FLASH 1085744 1085778 34 0.0
RAM 109029 109029 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 882236 882270 34 0.0
RAM 108596 108596 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 777384 777416 32 0.0
RAM 103404 103404 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 790136 790168 32 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 739392 739424 32 0.0
RAM 97612 97612 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 719564 719596 32 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 569670 569702 32 0.0
RAM 205112 205112 0 0.0
lock CC3235SF_LAUNCHXL FLASH 597230 597262 32 0.0
RAM 205272 205272 0 0.0
efr32 lighting-app BRD4187C FLASH 1104716 1104748 32 0.0
RAM 135360 135360 0 0.0
lock-app BRD4187C FLASH 995184 995216 32 0.0
RAM 131292 131292 0 0.0
BRD4338a FLASH 799825 799873 48 0.0
RAM 243432 243432 0 0.0
esp32 all-clusters-app c3devkit DRAM 99556 99556 0 0.0
FLASH 1626306 1626338 32 0.0
IRAM 94776 94776 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 845892 845928 36 0.0
RAM 157923 157923 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1752716 1752764 48 0.0
RAM 215644 215644 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1626564 1626596 32 0.0
RAM 211604 211604 0 0.0
light cy8ckit_062s2_43012 FLASH 1470876 1470908 32 0.0
RAM 197436 197436 0 0.0
lock cy8ckit_062s2_43012 FLASH 1504324 1504372 48 0.0
RAM 225268 225268 0 0.0
qpg lighting-app qpg6200+debug FLASH 843292 843324 32 0.0
RAM 127908 127908 0 0.0
lock-app qpg6200+debug FLASH 783064 783096 32 0.0
RAM 118840 118840 0 0.0
realtek light-switch-app rtl8777g FLASH 689984 690016 32 0.0
RAM 101880 101880 0 0.0
lighting-app rtl8777g FLASH 730320 730352 32 0.0
RAM 102052 102052 0 0.0
stm32 light STM32WB5MM-DK FLASH 478996 479028 32 0.0
RAM 141492 141492 0 0.0
telink light-app-ota-compress-lzma-factory-data tl3218x FLASH 800698 800732 34 0.0
RAM 42380 42380 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 742976 743010 34 0.0
RAM 34584 34584 0 0.0
all-devices-app tl7218x FLASH 881732 881766 34 0.0
RAM 99716 99716 0 0.0
bridge-app tl7218x FLASH 734172 734206 34 0.0
RAM 97700 97700 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl7218x FLASH 845838 845872 34 0.0
RAM 101492 101492 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 743060 743094 34 0.0
RAM 57924 57924 0 0.0
all-devices-app tlsr9118bdk40d FLASH 673338 673372 34 0.0
RAM 120848 120848 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 615230 615264 34 0.0
RAM 118508 118508 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 842054 842092 38 0.0
RAM 97376 97376 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 804148 804182 34 0.0
RAM 75276 75276 0 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant