Skip to content

Fix RDMA PollCq missing recv CQEs after re-arming the CQs - #3425

Open
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_poll_cq
Open

Fix RDMA PollCq missing recv CQEs after re-arming the CQs#3425
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_poll_cq

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve #3415

Problem Summary:

The completion notification requested by ibv_req_notify_cq() is one-shot: a CQE
that is already in the CQ when the CQ is armed does NOT generate a new completion
channel event. The standard pattern is therefore poll -> arm -> re-poll.

RdmaEndpoint::PollCq() polls recv_cq first and switches to send_cq once
recv_cq is empty. When both CQs are empty it arms them via
ReqNotifyCq(true) / ReqNotifyCq(false), but it keeps send = true and
cq = send_cq afterwards, so only send_cq is re-polled. recv_cq is never
re-polled although the comment right above claims it is.

As a result, if a solicited recv CQE arrives in the race window between
"poll recv_cq returns empty" and "arm recv_cq", the CQE is stranded in
recv_cq: no new event is delivered and no re-poll picks it up. The received
message is never handed to ProcessNewMessage(), and the connection stalls until
an unrelated CQE happens to arrive, which shows up as RPC timeouts.

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

PollCq only re-polled send_cq after arming both CQs, so a recv CQE
arriving in the one-shot notification race window of recv_cq was left
in the CQ and the RPC timed out. Restart the re-poll from recv_cq so
that both CQs are covered.

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.

Pull request overview

Fixes a race in RdmaEndpoint::PollCq() where a recv CQE could be stranded after re-arming CQs due to ibv_req_notify_cq() one-shot semantics, leading to stalled connections and RPC timeouts (issue #3415).

Changes:

  • After re-arming both send_cq and recv_cq, explicitly switches the polling state back to recv_cq.
  • Ensures the intended poll → arm → re-poll pattern is applied to both CQs, preventing missed recv CQEs in the poll/notify race window.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenBright
chenBright requested a review from yanglimingcn August 3, 2026 11:12
@yanglimingcn

Copy link
Copy Markdown
Contributor

LGTM

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.

RDMA::PollCq 复查逻辑缺陷:arm recv_cq 后未及时 re-poll,可能漏掉 recv CQE 并导致 RPC 超时

3 participants