Skip to content

Builtin EDP endpoints never re-match after a one-sided participant lease expiry (ReaderProxy ignores an ACKNACK below its low mark) #6658

Backlog

Description

@nchensel

Is there an already existing issue for this?

  • I have searched the existing issues

Searched open and closed issues and the 3.6.3 / master changelogs; none found.

Expected behavior

After a process is suspended for longer than the participant lease duration (for example SIGSTOP or docker pause for 11 s with leaseDuration 10 s) and then resumed, every endpoint pair between it and its peers matches again within a few announcement periods.

Current behavior

Some endpoint pairs stay unmatched for good: we watched for 60-120 s and longer, until a process was restarted. Which pairs varies from run to run. With ROS 2 (rmw_fastrtps_cpp) it mostly shows up as service clients that never see their server again, while topics between the same two participants recover: one SEDP channel stays stuck while the other recovers. Occasionally a topic is lost as well.

Analysis (3.6.2; the same code is in 3.6.3 and master):

  1. When both participants wake from the stall, each one's lease timer for the other races its reception of the other's DATA(p).
  2. Suppose participant B removes A, but A keeps B (a one-sided expiry):
    • B re-creates its WriterProxy for A's SEDP writers.
    • A keeps its ReaderProxy for B's SEDP readers, with changes_low_mark_ at A's last sequence number (everything acknowledged).
  3. If a HEARTBEAT from A reaches B's new WriterProxy before its initial ACKNACK goes out, B answers with ACKNACK base=1 and the whole history missing. (WriterProxy::perform_initial_ack_nack only sends the initial ACKNACK while last_heartbeat_count_ == 0.)
  4. In A, ReaderProxy::acked_changes_set(base=1) takes the seq_num <= changes_low_mark_ branch. The special case that rewinds the proxy only runs for seq_num == 0, which is the initial ACKNACK.
  5. requested_changes_set() then finds none of the requested changes in changes_for_reader_, and no GAP is sent either (sit <= changes_low_mark_).
  6. B NACKs on every heartbeat and A ignores it, so B never learns A's endpoints on that channel.

Steps to reproduce

A standalone reproducer is included below (run.sh, server.py, client.py, analyse.py; the profile is in the XML section). It needs only Docker and the public ros:lyrical-ros-base image:

./run.sh 10          # 10 runs; IMG=<image> overrides the image

Each run starts two containers on one Docker bridge. The profile sets UDPv4 only, leaseDuration 10 s and leaseAnnouncement 2 s.

  • Container F: 12 single-node processes (4 std_srvs/Trigger services and a 10 Hz status topic each), one process with 8 such nodes, and one client process that calls every service and GetParameters of every node once a second.
  • Container U: 8 more participants like these and the same client.

Once every call is answered, the script runs docker pause F for 11 s, then docker unpause F, and watches for 30 s. It reports each endpoint that never answered again.

Results:

Setup Runs with endpoint pairs lost for the whole watch
This reproducer, public ros:lyrical-ros-base (Fast DDS 3.6.2) 1 of 15 (F's client lost 17 endpoints of three server participants, including one status topic)
The same scripts on our own ROS 2 Lyrical image, Fast DDS 3.6.2 2 of 10
The same scripts on our image, with the patch below 0 of 10
Larger application (three containers, ~30 participants), 3.6.2 2 of 3
Same application, 3.6.3 built from source 3 of 3
Same application, 3.6.3 with the patch below 0 of 6 (every pair back within 2-6.4 s)

The failure is intermittent because it depends on the race in step 3 of the analysis, so a run of 10 or more is needed to see it with the small reproducer.

Reproducer scripts

run.sh

#!/bin/bash
# run.sh [RUNS]: freeze container F for 11 s (longer than the 10 s lease), watch 30 s, report endpoint pairs
# that never re-matched. Needs Docker and a ROS 2 image with rclpy and Fast DDS (IMG, default ros:lyrical-ros-base).
set -uo pipefail
HERE=$(cd "$(dirname "$0")" && pwd)
IMG=${IMG:-ros:lyrical-ros-base} RUNS=${1:-10} FREEZE=${FREEZE:-11} WATCH=${WATCH:-30}
NSERV=${NSERV:-12} K=${K:-4} MC=${MC:-8} UEXTRA=${UEXTRA:-8} DOMAIN=${DOMAIN:-42}
servers=$(seq -s, 0 $((NSERV-1)) | sed 's/\([0-9]*\)/s\1/g'),$(seq -s, 0 $((MC-1)) | sed 's/\([0-9]*\)/c_\1/g')
common=(-v "$HERE:/repro:ro" -e ROS_DOMAIN_ID=$DOMAIN -e PYTHONUNBUFFERED=1
        -e FASTDDS_DEFAULT_PROFILES_FILE=/repro/profile.xml -e RMW_IMPLEMENTATION=rmw_fastrtps_cpp)
docker network inspect ddsrepro >/dev/null 2>&1 || docker network create ddsrepro >/dev/null
bad=0
for run in $(seq 1 "$RUNS"); do
  out=$HERE/out/run$run; rm -rf "$out"; mkdir -p "$out"
  docker rm -f ddsrepro-F ddsrepro-U >/dev/null 2>&1
  # F (frozen): NSERV single-node servers, one process with MC nodes, one client of everything
  docker run -d --name ddsrepro-F --memory 3g --network ddsrepro "${common[@]}" --entrypoint bash "$IMG" -c "
    . /opt/ros/\$ROS_DISTRO/setup.bash
    for s in \$(seq 0 $((NSERV-1))); do python3 /repro/server.py s\$s $K > /tmp/s\$s.log 2>&1 & done
    python3 /repro/server.py c $K $MC > /tmp/c.log 2>&1 &
    python3 /repro/client.py cF $servers $K" >/dev/null
  # U (not frozen): UEXTRA more participants and the same client
  docker run -d --name ddsrepro-U --memory 2g --network ddsrepro "${common[@]}" --entrypoint bash "$IMG" -c "
    . /opt/ros/\$ROS_DISTRO/setup.bash
    for s in \$(seq 0 $((UEXTRA-1))); do python3 /repro/server.py u\$s $K > /tmp/u\$s.log 2>&1 & done
    python3 /repro/client.py cU $servers $K" >/dev/null
  t0=$(date +%s)                                   # wait until both clients have every endpoint answering
  while [ $(( $(date +%s) - t0 )) -lt 90 ]; do
    ok=1; for c in F U; do
      docker logs --tail 1 ddsrepro-$c 2>/dev/null | python3 -c "import json,sys;d=json.loads(sys.stdin.read() or '{}');sys.exit(0 if d and all(v=='ok' for v in d['out'].values()) else 1)" || ok=0
    done; [ $ok = 1 ] && break; sleep 1
  done
  sleep 3
  tp=$(date +%s.%N); docker pause ddsrepro-F >/dev/null; sleep "$FREEZE"
  tu=$(date +%s.%N); docker unpause ddsrepro-F >/dev/null
  sleep "$WATCH"
  docker logs ddsrepro-F > "$out/F.log" 2>&1; docker logs ddsrepro-U > "$out/U.log" 2>&1
  docker rm -f ddsrepro-F ddsrepro-U >/dev/null 2>&1
  res=$(python3 "$HERE/analyse.py" "$out" "$tp" "$tu"); echo "$res" > "$out/result.json"
  never=$(python3 -c "import json,sys;d=json.loads(sys.argv[1]);print(sum(len(v['never']) if isinstance(v,dict) else 1 for v in d['clients'].values()))" "$res")
  [ "$never" -gt 0 ] && bad=$((bad+1))
  echo "run $run: $never endpoints never re-matched in ${WATCH} s"
done
echo "TOTAL: $bad of $RUNS runs left endpoint pairs unmatched (freeze ${FREEZE} s, lease 10 s)"

server.py

#!/usr/bin/env python3
"""repro server: node NAME with K Trigger services, a 10 Hz status topic, and rclpy's parameter services."""
import sys
import rclpy
from rclpy.node import Node
from rclpy.qos import QoSProfile, QoSReliabilityPolicy
from std_msgs.msg import Header
from std_srvs.srv import Trigger


def make(name, k):
    n = Node(name, namespace='/repro')
    n.declare_parameter('x', 1)
    for i in range(k):
        n.create_service(Trigger, f'~/srv{i}', lambda req, res: (setattr(res, 'success', True), res)[1])
    pub = n.create_publisher(Header, '~/status', QoSProfile(depth=5, reliability=QoSReliabilityPolicy.BEST_EFFORT))

    def tick():
        h = Header()
        h.stamp = n.get_clock().now().to_msg()
        pub.publish(h)
    n.create_timer(0.1, tick)
    return n


def main():
    # server.py NAME K            one node (its own participant)
    # server.py NAME K M          M nodes NAME_0..NAME_{M-1} in one process (one participant: a component container)
    name, k = sys.argv[1], int(sys.argv[2])
    m = int(sys.argv[3]) if len(sys.argv) > 3 else 0
    rclpy.init()
    from rclpy.executors import SingleThreadedExecutor
    ex = SingleThreadedExecutor()
    nodes = [make(name, k)] if m == 0 else [make(f'{name}_{i}', k) for i in range(m)]
    for n in nodes:
        ex.add_node(n)
    print(f'server {name} up ({len(nodes)} nodes)', flush=True)
    try:
        ex.spin()
    except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
        pass


if __name__ == '__main__':
    main()

client.py

#!/usr/bin/env python3
"""repro client CNAME SERVERS K: per server node, K Trigger clients + a GetParameters client + a status subscription.
Every PERIOD s prints one JSON line: per endpoint service_is_ready, last call outcome, topic age."""
import json
import sys
import time
import rclpy
from rclpy.node import Node
from rclpy.qos import QoSProfile, QoSReliabilityPolicy
from rcl_interfaces.srv import GetParameters
from std_msgs.msg import Header
from std_srvs.srv import Trigger

PERIOD = 1.0
CALL_TIMEOUT = 2.0


def main():
    cname, servers, k = sys.argv[1], sys.argv[2].split(','), int(sys.argv[3])
    rclpy.init()
    n = Node(cname, namespace='/repro_c')
    cl = {}
    for s in servers:
        for i in range(k):
            cl[f'{s}/srv{i}'] = (n.create_client(Trigger, f'/repro/{s}/srv{i}'), Trigger.Request())
        req = GetParameters.Request(); req.names = ['x']
        cl[f'{s}/params'] = (n.create_client(GetParameters, f'/repro/{s}/get_parameters'), req)
    last = {}
    for s in servers:
        n.create_subscription(Header, f'/repro/{s}/status', (lambda s: lambda m: last.__setitem__(s, time.time()))(s),
                              QoSProfile(depth=5, reliability=QoSReliabilityPolicy.BEST_EFFORT))
    pending = {}     # key -> (future, t_sent)
    outcome = {k: 'none' for k in cl}

    def tick():
        now = time.time()
        for key, (c, req) in cl.items():
            p = pending.get(key)
            if p is not None:
                f, t0 = p
                if f.done():
                    outcome[key] = 'ok'
                    pending.pop(key)
                elif now - t0 > CALL_TIMEOUT:
                    outcome[key] = 'timeout'
                    c.remove_pending_request(f)
                    pending.pop(key)
                else:
                    continue
            if c.service_is_ready():
                pending[key] = (c.call_async(req), now)
            else:
                outcome[key] = 'not_ready'
        rec = {'t': round(now, 3), 'c': cname,
               'ready': {k: cl[k][0].service_is_ready() for k in cl},
               'out': dict(outcome),
               'age': {s: (round(now - last[s], 2) if s in last else None) for s in servers}}
        print(json.dumps(rec), flush=True)
    n.create_timer(PERIOD, tick)
    try:
        rclpy.spin(n)
    except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
        pass


if __name__ == '__main__':
    main()

analyse.py

#!/usr/bin/env python3
"""analyse.py OUT T_PAUSE T_UNPAUSE: per client and endpoint, when it was healthy again after the unpause
(two polls in a row: call answered 'ok' / topic age < 1 s), or never."""
import json, sys
out, tp, tu = sys.argv[1], float(sys.argv[2]), float(sys.argv[3])
res = {'freeze_s': round(tu - tp, 2), 'clients': {}}
for c in ('F', 'U'):
    recs = []
    for l in open(f'{out}/{c}.log'):
        if l.startswith('{'):
            try: recs.append(json.loads(l))
            except ValueError: pass
    post = [r for r in recs if r['t'] > tu + 0.5]
    if not post:
        res['clients'][c] = 'no records after unpause'; continue
    keys = list(post[0]['out']) + [f'topic:{s}' for s in post[0]['age']]
    rec_s = {}
    for k in keys:
        ok = [ (r['out'][k] == 'ok') if not k.startswith('topic:') else
               (r['age'][k[6:]] is not None and r['age'][k[6:]] < 1.0) for r in post]
        t = None
        for i in range(len(post) - 1):
            if ok[i] and ok[i + 1] and all(ok[i:]):     # healthy from here to the end of the watch
                t = round(post[i]['t'] - tu, 1); break
        rec_s[k] = t
    never = sorted(k for k, v in rec_s.items() if v is None)
    last = post[-1]
    res['clients'][c] = {'n': len(rec_s), 'never': never, 'max_recover_s': max([v for v in rec_s.values() if v is not None], default=None),
                         'watched_s': round(last['t'] - tu, 1),
                         'never_detail': {k: {'ready': last['ready'].get(k), 'out': last['out'].get(k)} for k in never if not k.startswith('topic:')}}
print(json.dumps(res))

run.sh reads profile.xml from its own directory: save the XML from the section below under that name.

Fix that works for us

Treat an ACKNACK whose base is at or below the low mark of a remote, non-volatile reader as coming from a reader that lost its state, and rewind the proxy as for the initial ACKNACK, so the writer resends its history to it. Against 3.6.3:

--- a/src/cpp/rtps/writer/ReaderProxy.cpp
+++ b/src/cpp/rtps/writer/ReaderProxy.cpp
@@ -404,7 +404,8 @@ void ReaderProxy::acked_changes_set(
     {
         future_low_mark = changes_low_mark_ + 1;
 
-        if (seq_num == SequenceNumber_t() && durability_kind_ != DurabilityKind_t::VOLATILE)
+        const bool reader_rewound = seq_num != SequenceNumber_t() && seq_num <= changes_low_mark_ && !is_local_reader();
+        if ((seq_num == SequenceNumber_t() || reader_rewound) && durability_kind_ != DurabilityKind_t::VOLATILE)
         {

Points we checked:

  • A delayed or duplicate ACKNACK can't trigger the rewind. StatefulWriter::process_acknack only calls acked_changes_set after ReaderProxy::check_and_set_acknack_count has accepted the ACKNACK's count, which must not be lower than the next expected count. A stale ACKNACK is therefore discarded before it reaches this code.
  • The other callers of acked_changes_set are unaffected. Intra-process delivery uses local readers, which !is_local_reader() excludes. The best-effort paths pass increasing sequence numbers, so they don't hit the low-mark branch in normal operation.
  • The change also applies to user transient-local writers, not only builtin SEDP. For those, resending the history to a reader that has lost its state is the same behaviour the initial ACKNACK already gets.
  • A narrower option. You may prefer to do the rewind in StatefulWriter::process_acknack, so only a real ACKNACK can trigger it. Alternatively, the fix could go on the WriterProxy side, so the re-created proxy always sends its initial ACKNACK first. We are happy to adapt the change.

We can open a pull request with a regression test once you agree on the approach.

Fast DDS version/commit

3.6.2 (ros-lyrical-fastdds 3.6.2-1noble.20261117). Also 3.6.3 built from source, with the same failure.

Platform/Architecture

Other. Please specify in Additional context section.

Transport layer

UDPv4

Additional context

Ubuntu 24.04, arm64 (NVIDIA Jetson AGX Thor, L4T R39.2.1), ROS 2 Lyrical with rmw_fastrtps_cpp.

XML configuration file

<?xml version="1.0" encoding="UTF-8" ?>
<dds xmlns="http://www.eprosima.com">
  <profiles>
    <participant profile_name="repro_participant" is_default_profile="true">
      <rtps>
        <builtinTransports>UDPv4</builtinTransports>
        <builtin>
          <discovery_config>
            <leaseDuration><sec>10</sec></leaseDuration>
            <leaseAnnouncement><sec>2</sec></leaseAnnouncement>
          </discovery_config>
        </builtin>
      </rtps>
    </participant>
  </profiles>
</dds>

Relevant log output

No response

Network traffic capture

No response

Activity

  1. nchensel commented on Nov 29, 2026

    @nchensel
    Author

    Two corrections to the description above, found while reviewing the patch for 3.6.3.

    1. On 3.6.3 the stuck reader is sent a GAP rather than nothing. Step 5 of the analysis holds for 3.6.2. In 3.6.3, #6542 added a block to StatefulWriter::process_acknack that runs after acked_changes_set. For any ACKNACK at or below the reader's low mark, it sends a GAP over [max(base, seq_num_min), low_mark], whatever the reader's durability. So in the one-sided case, the re-created builtin SEDP reader is told that the writer's whole history is irrelevant, and it never learns those endpoints.

    That fits what we measured: 3.6.3 lost pairs in 3 of 3 runs of the larger application, against 2 of 3 on 3.6.2. The proposed change still fixes it, because the rewind in acked_changes_set resets the low mark before that block runs, so no GAP covers the history and the requested changes are resent.

    2. The rewind should be limited to reliable readers. The version we now carry adds is_reliable_ to the condition. Builtin SEDP readers are reliable and transient-local (EDPSimple.cpp), so the discovery case is unchanged. The added condition keeps best-effort paths that call acked_changes_set directly from triggering a rewind.

    There is one more writer-side path we found: ack_timer_expired for readers with disable_positive_acks. It can call acked_changes_set below the low mark and would rewind needlessly. The effect is harmless and heals itself, but !disable_positive_acks_ in the condition, or doing the rewind in process_acknack itself, avoids it.

    The change we carry, against 3.6.3:

    --- a/src/cpp/rtps/writer/ReaderProxy.cpp
    +++ b/src/cpp/rtps/writer/ReaderProxy.cpp
    @@ -404,7 +404,9 @@ void ReaderProxy::acked_changes_set(
         {
             future_low_mark = changes_low_mark_ + 1;
     
    -        if (seq_num == SequenceNumber_t() && durability_kind_ != DurabilityKind_t::VOLATILE)
    +        const bool remote_reader_lost_state = seq_num != SequenceNumber_t() && is_reliable_ && !is_local_reader();
    +        if ((seq_num == SequenceNumber_t() || remote_reader_lost_state) &&
    +                durability_kind_ != DurabilityKind_t::VOLATILE)
             {

    (This sits in the branch that only runs for seq_num <= changes_low_mark_, so that comparison is not repeated.)

    We added two unit tests to ReaderProxyTests. The main one, an ACKNACK below the low mark rewinds a transient-local reliable reader, fails on unpatched 3.6.3 and passes with the change. Neither test yet covers the ordering against the #6542 GAP block in process_acknack, which a regression test in a PR should. We are still happy to open that PR once you agree on where the rewind should live.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions