Skip to content

fix(rtps): ActionClient::wait_for_server() also waits for the feedback writer - #963

Merged
finger563 merged 2 commits into
mainfrom
test/typed-action-feedback-race
Dec 1, 2026
Merged

finger563 merged 2 commits into
mainfrom
test/typed-action-feedback-race

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

typed_action_alignment kept failing on the Jazzy interop runner after #939, in the same way. The first goal succeeds, but its one feedback sample never arrives:

succeed: status 4, result {1.5, 7, 2.5}, feedback {-1, -1}
FAIL: the feedback's int32 and double arrived intact (line 199)

(run 46583796982, on #959, which only touched the Python bindings).

Root cause

#939 made the test wait until the server's feedback writer has matched the client's reader. The other half of the match was still open: the client's feedback reader may not have matched the server's writer when the sample arrives, and a reader drops samples from a writer it doesn't know yet. The goal finishes in milliseconds, so that one sample was the only chance.

ActionClient::wait_for_server() waited for the three services only. rcl_action_server_is_available(), which rclcpp_action's wait_for_action_server() polls, also requires a publisher matched to the client's feedback subscription.

Change

  • Engine: ActionClient::server_count(), and so wait_for_server(), now also counts the writers matched to the client's feedback reader. espp's action client has no status subscription, so feedback is the one topic to add.
  • Test: asserts client.matched_writers(feedback_topic) >= 1 after wait_for_server(). It keeps test(rtps): typed_action_alignment waits for the feedback reader to match #939's server-side wait, because a volatile writer only sends to readers it has matched. Nothing on the client side can observe that, and rclcpp has the same window.
  • Docs: the header and the Python docstring are updated, and the regenerated stub differs from main by that one docstring line (generate_stubs.py --check passes). rtps_rmi_ami.rst gets a short note too.

Test plan

  • typed_action_alignment locally (macOS, Release, as run_interop.sh builds it). The race doesn't reproduce here: before the fix, 0 of 100 runs idle and 0 of 200 under CPU load (2 × ncpu spinners) failed. After the fix, 0 of 200 failed. CI's Jazzy interop is where it showed up, roughly once in several runs.
  • The other action and RPC pc tests pass: rtps_action_* (cancel codes, goal flood, long goal, loopback, naming, types, worker pool) and rtps_rpc_* (empty reply, pending eviction, stop race).
  • The Python tests that use the action client pass: rtps_bindings_smoke, rtps_bindings_misuse_test, rtps_rpc_timeouts_test, rtps_task_configs_test, typing_api_test.
  • CI: interop (Humble / Jazzy), QEMU.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

…k writer

typed_action_alignment kept failing on the Jazzy interop runner the same
way after #939: the first goal succeeds, its one feedback sample never
arrives ("feedback {-1, -1}").

#939 made the test wait until the SERVER's feedback writer has matched
the client's reader. The other half was still open: the CLIENT's feedback
reader may not have matched the server's writer yet when that sample
arrives, and a reader drops a sample from a writer it does not know.
wait_for_server() covered the three services only, while
rcl_action_server_is_available() (what rclcpp_action's
wait_for_action_server() polls) also requires a publisher matched to the
client's feedback subscription.

ActionClient::server_count() - and so wait_for_server() - now also counts
the writers matched to the client's feedback reader. The test asserts it
after wait_for_server() and keeps the server-side wait (a volatile writer
only sends to readers it has matched; nothing on the client side can see
that, rclcpp has the same window). Docs (header, Python docstring and the
regenerated stub, rtps_rmi_ami.rst) say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Ensures ActionClient::wait_for_server() waits for the feedback data path to be discoverable end-to-end to avoid dropping the first (often only) feedback sample in fast goals during interop runs.

Changes:

  • Extend ActionClient::server_count()/wait_for_server() to include matched writers on the feedback topic.
  • Strengthen typed_action_alignment by asserting client-side feedback writer match after wait_for_server().
  • Update documentation (C++ header, Python bindings/stubs, RST protocol doc) to reflect the new wait semantics.
File Description
pc/​tests/​rtps_typed_action_alignment.cpp Adds an assertion that wait_for_server() covers feedback writer matching and preserves server-side match wait.
lib/​python_bindings/​rtps_bindings.cpp Updates Python docstring to reflect feedback-topic matching in server_count().
lib/​python_bindings/​espp/​_espp/​__init__.pyi Regenerates stub docstring to include feedback topic matching.
doc/​en/​protocols/​rtps_rmi_ami.rst Documents that wait_for_server() also waits for feedback writer matching to prevent first-feedback loss.
components/​rtps/​src/​rtps_participant.cpp Implements feedback-writer matching in ActionClient::server_count().
components/​rtps/​include/​rtps_participant.hpp Updates C++ API docs for server_count() and wait_for_server() to include feedback matching.

Review effort: Lite

Comment thread doc/en/protocols/rtps_rmi_ami.rst Resolved
- the feedback topic name is built once (ActionClient::Impl::feedback_topic)
  instead of on every server_count() call, which wait_for_server() polls;
- the comment and the RMI / AMI doc say why the first feedback was lost:
  the client's reader drops samples from a writer it has not discovered and
  matched yet, and the volatile feedback topic does not resend them (rcl
  also checks the status topic; this client subscribes to feedback only);
- the Python docstring of ActionClient.server_count wraps (the stub is
  regenerated from the built module).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

rtps memory footprint (QEMU, esp32)

Deltas in parentheses are against main @ 829c8fd (run 46688952857): a bigger size or a smaller free heap than the baseline's is a cost of this change.

librtps.a in the image (bytes, idf.py size-components)

embedded host host_large
flash code 162,127 (-95) 163,485 (-103) 163,897 (-95)
flash data 1,272 (+0) 1,272 (+0) 1,272 (+0)
DRAM (.data + .bss) 126 (+0) 126 (+0) 126 (+0)
IRAM 0 (+0) 0 (+0) 0 (+0)

engine objects, sizeof (bytes; the Domain is allocated from the heap at start())

object embedded host host_large
rtps::Domain (holds every pool below) 99,208 (+0) 569,968 (+0) 3,156,208 (+0)
rtps::Participant 34,304 (+0) 42,736 (+0) 52,720 (+0)
rtps::StatefulWriter 2,528 (+0) 2,960 (+0) 6,416 (+0)
rtps::StatelessWriter 1,872 (+0) 2,256 (+0) 3,792 (+0)
rtps::StatefulReader 1,968 (+0) 2,008 (+0) 2,104 (+0)
rtps::StatelessReader 1,960 (+0) 2,000 (+0) 2,096 (+0)
espp::RtpsParticipant 608 (+0) 608 (+0) 608 (+0)

embedded: heap by stage (free bytes; a cost is a negative delta)

stage internal delta internal low-water mark largest internal block PSRAM delta
boot 220,279 (+0) 219,552 (+0) 131,072 4,191,440 (+0)
started 159,843 (-160) -60,436 159,272 (-100) 73,728 4,090,208 (+0) -101,232
endpoints 139,503 (-8) -20,340 138,128 (-8) 69,632 4,090,208 (+0) +0

embedded: heap after each host-driven step (free bytes; deltas against the previous row; the pools are preallocated, so a peer costs little heap - the low-water mark shows the transients)

step internal delta internal low-water mark largest internal block PSRAM delta
baseline 133,255 (+8) 132,168 (+4) 69,632 4,090,228 (+12)
+1 remote participant (no match) 133,139 (+20) -116 130,440 (-460) 69,632 4,090,228 (+0) +0
+1 more remote participant (no match) 133,111 (+8) -28 130,440 (-460) 69,632 4,090,228 (+0) +0
+1 remote participant with a matched publisher 133,091 (+8) -20 130,440 (-460) 69,632 4,090,228 (+0) +0
after a service call 133,075 (+4) -16 130,440 (-460) 69,632 4,090,228 (+0) +0
after an action goal 131,867 (-12) -1,208 130,192 (-48) 69,632 4,090,228 (+0) +0
after one 30 KB sample 131,871 (-8) +4 129,848 (-8) 69,632 4,060,016 (+0) -30,212
all peers gone 131,855 (-24) -16 129,848 (-8) 69,632 4,060,016 (+0) +0

host: heap by stage (free bytes; a cost is a negative delta)

stage internal delta internal low-water mark largest internal block PSRAM delta
boot 219,047 (+0) 218,320 (+0) 131,072 4,191,440 (+0)
started 130,575 (-20) -88,472 129,980 (+0) 69,632 3,617,120 (+12) -574,320
endpoints 109,775 (-136) -20,800 108,400 (-136) 69,632 3,617,120 (+12) +0

host_large: the participant did not start on this target - the profile does not fit (panicked while the engine was being built - internal RAM exhausted building the Domain's mutexes (the first error logged: [RtpsTransport/E][3.007]: Failed to create valid UDP socket for port 7401)); its sizeof is in the table above, the boot heap below

host_large: heap by stage (free bytes; a cost is a negative delta)

stage internal delta internal low-water mark largest internal block PSRAM delta
boot 219,047 (+0) 218,320 (+0) 131,072 4,191,440 (+0)
started n/a
endpoints n/a

The QEMU memory suite on 7b55f23 (run); the full numbers are the run's rtps-memory artifact.

@finger563
finger563 merged commit 6f152f5 into main Dec 1, 2026
206 checks passed
@finger563
finger563 deleted the test/typed-action-feedback-race branch December 1, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants