Skip to content

UCP/FT: Replay the recovery queue once the held lanes are purged - #12449

Open
dmitrygx wants to merge 2 commits into
openucx:masterfrom
dmitrygx:topic/ucx/tf-replay-purged-v2
Open

dmitrygx wants to merge 2 commits into
openucx:masterfrom
dmitrygx:topic/ucx/tf-replay-purged-v2

Conversation

@dmitrygx

@dmitrygx dmitrygx commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What?

With token failover, send the requests from the pending queue of a held lane as
soon as the lane is purged, instead of when the recovery of the endpoint ends.

Depends on #12448

Why?

Token failover moved these requests to a recovery queue, and replayed it only
when the failed lanes recovered or the retries ran out. With the default
UCX_RECOVERY_RETRIES=inf, they waited as long as the NIC was down, although
the live lanes could send them. With NIXL on systems with two NICs per GPU,
transfers stalled while one NIC was down. A closed endpoint canceled them.

test_ucp_ft_tf_hold.parked_put_lane_down without the fix
[ RUN      ] rcx/test_ucp_ft_tf_hold.parked_put_lane_down/0 <rc_x/rma>
[     INFO ] put/offload/zcopy of 1024 bytes on lanes 0x1
[...] ucp_test.cc:311  UCX  ERROR request 0x43020a0 did not complete on time
test/gtest/ucp/test_ucp_fault_tolerance.cc:1908: Failure
Expected equality of these values:
  UCS_OK
    Which is: 0
  _status
    Which is: 1
Error: Operation in progress
test/gtest/ucp/test_ucp_fault_tolerance.cc:1909: Failure
Value of: is_delivered()
  Actual: false
Expected: true
put data was not delivered
test/gtest/common/test.cc:456: Failure
Failed
Got 1 errors and 0 warnings during the test
[  FAILED  ] rcx/test_ucp_ft_tf_hold.parked_put_lane_down/0, where GetParam() = rc_x/rma (180925 ms)
NIXL e2e without the fix: vLLM 1P1D, one of the two NICs down for 120 s
# UCX on the decode side when the NIC goes down
ib_mlx5_log.c:174  UCX  DIAG  Transport retry count exceeded on mlx5_5:1/IB (synd 0x15 vend 0x81 hw_synd 0/0)
|           | mlx5_5:1           |       2 | am, am_bw, rma_bw, failed         |

# The same 32 prompts before, during and after the drop, KV pull
before.jsonl: 32 prompts, 0 failed
during.jsonl: 32 prompts, 1 failed (first: [1]: TimeoutError:), 0 differ from before.jsonl
after.jsonl: 32 prompts, 0 failed, 0 differ from before.jsonl
RESULT: FAILED (1 failed, 0 differ)

# KV push
during.jsonl: 32 prompts, 1 failed (first: [0]: TimeoutError:), 0 differ from before.jsonl
RESULT: FAILED (1 failed, 0 differ)

The requests which started around the drop got their first token only after
the NIC came back.

How?

  • ucp_ep_tf_resume() replays the queue once no held lane is left unpurged:
    right after the purge, or from a progress callback when the purge comes from
    the wireup message handler, which can run on the async thread. A failed
    endpoint cancels the queue; a closed one now replays it.
  • A request of several fragments can wait in the queue with operations in
    flight, and a restart would reset its completion count under them. It drops
    its sending reference with an error instead, so its last completion restarts
    it, as after a failed operation.
  • Known gap: with UCX_MAX_EAGER_LANES > 1, the receiver can drop a restarted
    AM message of several fragments by its PSN check, if a later message arrived
    first. Messages sent during the hold can already overtake the queue this way.
    Left for a separate change.
  • Tests: test_ucp_ft_tf_hold, a put parked on a lane which stays down, and
    parked requests of several fragments.

Token failover holds a failed lane until the peer returns its token. It
reposts the operations outstanding on the lane, and moves the requests
from the pending queue of the lane to the recovery queue. The recovery
queue is replayed only when the recovery of the endpoint ends, so a
request which waits there does not complete while the failed lane is
down, even though the live lanes could send it.

Add test_ucp_ft_tf_hold.parked_put_lane_down: a put waits in the pending
queue of a lane which fails, and whose probes keep failing. The put must
complete, and its data must arrive, while the lane is down. It fails
now.

Add test_ucp_ft_tf_hold.parked_{get_bcopy,get_zcopy,put_zcopy}: a
request of several fragments posts some of them on a lane which fails,
and then waits in its pending queue. The token purge reposts these
fragments, and the replay restarts the request. The request must
complete once, after all of its data arrived, and no fragment may
complete or write after it. The 2_rails variants send the request on two
lanes, and keep a fragment on the live lane in flight until after the
purge: the request must not complete before the test completes that
fragment. These tests pass now, since the reposts and the fragment
complete before the recovery ends.

The fixture finds the lanes of an RMA operation which token failover can
hold, and parks a request in the recovery queue.
Token failover moves the requests from the pending queue of a held lane
to the recovery queue, and replayed the queue only when the recovery of
the endpoint ended: when the failed lanes recovered, or when the retries
ran out. With the default UCX_RECOVERY_RETRIES=inf, a lane which does
not recover kept them forever, so a request issued before the failure
stalled although the live lanes could send it. A closed endpoint
canceled the queue when the recovery ended, although its requests were
issued before the close.

Replay the recovery queue as soon as no held lane has outstanding
operations left to purge, so the requests follow the operations which
the token purge reposted on the live lanes. The purge from a progress
callback replays the queue at once. The purge of a LANES_ADDR message
replays it from a progress callback, since the wireup message handler
can run on the async thread. A closed endpoint replays the queue too,
and a failed endpoint still cancels it.

The replay restarts a request: its reset rewinds it, and sets the count
of its completion to 1. A request of several fragments counts its
operations in flight in that count, plus one reference until it sends
all of its data. It can wait in the recovery queue while operations it
posted did not complete: in flight on a live lane, or reposted by the
purge. A restart would let their completions complete the restarted
request before its data arrived. Such a request drops its reference with
an error instead: when its last operation completes, the error restarts
it, as after a failed operation. It restarts after the requests queued
behind it.

test_ucp_ft_tf_hold.parked_put_lane_down passes now, and the other
parked tests still pass.
@dmitrygx
dmitrygx requested a review from a team as a code owner November 24, 2026 00:24
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/ucp/core/ucp_ep.c
ucs_queue_head_init(&replay_q);
ucs_queue_for_each_extract(self, &arg->tf_pending_q, priv, 1) {
req = ucs_container_of(self, ucp_request_t, send.uct);
if (ucp_ep_tf_req_in_flight(req)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we keep subsequent flushes blocked until these deferred sends have restarted? Removing a partially sent request from the pending queue leaves its remaining data unposted until the last outstanding completion triggers a restart; a following flush can cover only the old fragments and complete before the restarted transfer finishes, breaking flush and graceful-close guarantees.

@svc-ucx

svc-ucx commented Nov 24, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX-OSS/ucx-coverity-oss · commit aa8d3a50

TL;DR: The Coverity stage failed because cov-format-errors reported 1 un-suppressed defect — a MISSING_MOVE_ASSIGNMENT on ucs::handle<ucp_rkey*, void*> (test_helpers.h:701) newly triggered by the rvalue copy-assignment m_rkey = m_rbuf->rkey(sender()); added in the new fault-tolerance RMA test; fix it by giving ucs::handle a move assignment operator (or by using m_rkey.reset(...) instead of assigning a returned-by-value handle).

Full analysis

Summary: UCX-OSS/ucx-coverity-oss #189 stage "Coverity" failed: cov-analyze finished successfully but nerrors=1, so buildlib/tools/coverity.sh returned non-zero.

Root cause: From the stage log: the build and analysis completed ("The cov-build utility completed successfully", "Defect occurrences found : 1869 Total … 1 MISSING_MOVE_ASSIGNMENT"), then:

+ nerrors=1
+ '[' 1 -gt 0 ']'
...
/.../test/gtest/common/test_helpers.h:701
  Type: Missing move assignment operator (MISSING_MOVE_ASSIGNMENT)
  missing_move_assignment: Class "ucs::handle<ucp_rkey *, void *>" may benefit
  from adding a move assignment operator...
/.../test/gtest/ucp/test_ucp_fault_tolerance.cc:1667: Supporting evidence set 1:
  copy_assignment: Example 1: Copy assignment is performed on an object (rvalue)
  of type "ucs::handle<ucp_rkey *, void *>".

buildlib/tools/coverity.sh:112 fails the job on any non-zero nerrors, so this single informational C++ defect is a hard build break. ucs::handle (test/gtest/common/test_helpers.h:700-795) declares only const handle& operator=(const handle&) — a copy assignment that fakes move semantics by calling other.revoke() on a mutable flag — and no operator=(handle&&). The new fault-tolerance test assigns a handle returned by value from mapped_buffer::rkey() (m_rkey = m_rbuf->rkey(sender());, line 1667 of the branch revision / line 1594 in the current file), which is the rvalue copy-assignment Coverity flags. test_helpers.h itself hasn't changed since Aug 2026, so the defect was introduced by the new test code, not by the helper.

Implicated commit: 5905e19 — "GTEST/UCP/FT: Test requests which wait in the recovery queue", Dmitrii, 2026-11-23 (PR #12449, branch topic/ucx/tf-replay-purged-v2)

File: test/gtest/ucp/test_ucp_fault_tolerance.cc:1667 (m_rkey = m_rbuf->rkey(sender());), defect reported against test/gtest/common/test_helpers.h:701

Suggested fix: Preferred — add a real move assignment (and move constructor) to ucs::handle in test/gtest/common/test_helpers.h, which both silences the checker and makes the existing ownership-stealing operator= semantics explicit, e.g.:

handle(handle&& other) noexcept : m_initialized(false), m_value(NULL),
                                  m_dtor(NULL), m_dtor_with_arg(NULL),
                                  m_dtor_arg(NULL) {
    *this = std::move(other);
}

handle& operator=(handle&& other) noexcept {
    reset();
    if (other.m_initialized) {
        m_value         = other.m_value;
        m_dtor          = other.m_dtor;
        m_dtor_with_arg = other.m_dtor_with_arg;
        m_dtor_arg      = other.m_dtor_arg;
        m_initialized   = true;
        other.revoke();
    }
    return *this;
}

Minimal alternative in the test: avoid assigning the temporary, e.g. m_rkey.reset(m_rbuf->rkey(sender()).get(), ucp_rkey_destroy); (or have the test hold the handle by construction rather than assignment). Do not fix this by disabling the checker in buildlib/tools/coverity.sh unless the team explicitly wants MISSING_MOVE_ASSIGNMENT (a C++11 performance checker pulled in by --all) excluded project-wide.

Related: PR #12449 (this change); prior Coverity-driven test cleanups: #12209 "Coverity: Uninitialized variable fixes for Coverity 2026.3.0 Upgrade"

@svc-ucx

svc-ucx commented Nov 24, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Coverity coverity devel on coverity_rh7) · commit aa8d3a50

TL;DR: The Coverity devel job failed because a single new static-analysis defect (MISSING_MOVE_ASSIGNMENT) was introduced: the new FT test assigns a returned temporary ucs::handle<ucp_rkey*, void*> (m_rkey = m_rbuf->rkey(sender())), and ucs::handle has only a copy-assignment operator. Fix by adding a move-assignment operator to ucs::handle (or avoiding the rvalue assignment in the test, e.g. via m_rkey.reset(...)/a named lvalue).

Full analysis

Summary: coverity devel on coverity_rh7 (Azure build 147362) failed at the end of cov-analyze/cov-format-errors with ##[error]Coverity found 1 issues — the build/compile itself succeeded (758/758 translation units, "cov-build utility completed successfully").

Root cause: From the log:

/__w/1/s/test/gtest/common/test_helpers.h:701
  Type: Missing move assignment operator (MISSING_MOVE_ASSIGNMENT)
  missing_move_assignment: Class "ucs::handle<ucp_rkey *, void *>" may benefit from
  adding a move assignment operator...
/__w/1/s/test/gtest/ucp/test_ucp_fault_tolerance.cc:1667: Supporting evidence set 1:
  copy_assignment: Copy assignment is performed on an object (rvalue) of type
  "ucs::handle<ucp_rkey *, void *>".

ucs::handle (test/gtest/common/test_helpers.h:701) declares a user copy constructor, destructor and const handle& operator=(const handle&) (line 768) but no move assignment operator, so the implicit move-assign is suppressed. The new fault-tolerance test code added by this PR does an rvalue copy-assignment at test/gtest/ucp/test_ucp_fault_tolerance.cc:1594:

m_rkey = m_rbuf->rkey(sender());   // rkey() returns ucs::handle<ucp_rkey_h> by value

Coverity flags that rvalue copy-assignment, the job script computes nerrors=1 and fails the stage ([[ 1 -eq 0 ]] → exit non-zero). The error count gate means any single new defect fails the job, so this is a real (though benign-looking) new finding, not infrastructure flakiness or a timeout.

Implicated commit: 5905e191 — Dmitrii, "GTEST/UCP/FT: Test requests which wait in the recovery queue" (PR #12449, branch topic/ucx/tf-replay-purged-v2; built as merge commit aa8d3a50)

File: test/gtest/ucp/test_ucp_fault_tolerance.cc:1594 (defect reported against test/gtest/common/test_helpers.h:701, assignment operator at test_helpers.h:768)

Suggested fix: Preferred — give ucs::handle an explicit move assignment operator (and move ctor) so rvalue assignments stop being flagged; the existing copy-assign already has move semantics (it calls other.revoke()), so this is a trivial, behavior-preserving addition (gtest is built with -std=c++11, so this is legal):

handle(handle&& other) : m_initialized(false), m_value(NULL), m_dtor(NULL),
                         m_dtor_with_arg(NULL), m_dtor_arg(NULL) {
    *this = std::move(other);
}

handle& operator=(handle&& other) {
    reset();
    if (other.m_initialized) {
        if (other.m_dtor) {
            reset(other.m_value, other.m_dtor);
        } else {
            reset(other.m_value, other.m_dtor_with_arg, other.m_dtor_arg);
        }
        other.m_initialized = false;
    }
    return *this;
}

Minimal alternative (keeps the header untouched): avoid assigning from a temporary in the new test, e.g.

ucs::handle<ucp_rkey_h> rkey = m_rbuf->rkey(sender());  // direct-init, no assignment
m_rkey = rkey;

or construct the rkey directly into m_rkey with m_rkey.reset(...). Note the supporting evidence line is the only occurrence, so one of these is enough to clear the gate.

Related: PR #12449 (this change); prior Coverity-cleanup precedent: 9d965fa6 "Coverity: Uninitialized variable fixes for Coverity 2026.3.0 Upgrade (#12209)"

This branch has not been deployed

No deployments
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.

3 participants