From 2dd196e855dcc0e1572b59b0602fbf9cfb9d2e36 Mon Sep 17 00:00:00 2001 From: chenBright Date: Mon, 3 Aug 2026 22:36:17 +0800 Subject: [PATCH] Fix RDMA PollCq missing recv CQEs after re-arming the CQs 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. --- src/brpc/rdma/rdma_endpoint.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/brpc/rdma/rdma_endpoint.cpp b/src/brpc/rdma/rdma_endpoint.cpp index 6c20ea3994..8660d8d963 100644 --- a/src/brpc/rdma/rdma_endpoint.cpp +++ b/src/brpc/rdma/rdma_endpoint.cpp @@ -1492,6 +1492,17 @@ void RdmaEndpoint::PollCq(Socket* m) { return; } notified = true; + // Both CQs have just been re-armed, thus both of them must be + // re-polled. Note that `cq' is `send_cq' here, so we have to + // switch back to `recv_cq' explicitly. Otherwise only + // `send_cq' would be re-polled, and a recv CQE arriving in + // the window between the poll and the notify of `recv_cq' + // would be left in the CQ without any following event + // (one shot notification is not triggered by the CQE which + // is already in the CQ before the arming), which stalls the + // connection until the next CQE happens to come. + send = false; + cq = ep->_resource->recv_cq; continue; } if (!m->MoreReadEvents(&progress)) {