Copilot commented on code in PR #3708:
URL: https://github.com/apache/brpc/pull/3708#discussion_r4586357002
##########
src/brpc/urma/mock_urma.cpp:
##########
@@ -617,6 +631,9 @@ urma_status_t urma_post_jetty_send_wr(urma_jetty_t *jetty,
urma_jfs_wr_t *wr,
recv_cr.imm_data = current->send.imm_data;
PushCompletion(remote_jfc, remote_state, recv_cr);
}
+ // A SEND completion lets the consumer release its source buffers.
+ // Finish copying the payload before publishing that completion.
+ complete_send();
Review Comment:
`complete_send()` is unconditional after the copy, even when `remote_state`
is null and no receive completion was queued. In that teardown/race case the
mock reports a successful source-buffer completion although the peer has no
completion telling it that the payload arrived, so the sender can reclaim data
that was not observable by the receiver. Only publish the SEND completion once
both delivery and the corresponding receive completion have been successfully
queued, or propagate a failure.
##########
src/brpc/urma/mock_urma.cpp:
##########
@@ -556,21 +566,24 @@ urma_status_t urma_post_jetty_send_wr(urma_jetty_t
*jetty, urma_jfs_wr_t *wr,
return URMA_EINVAL;
}
- urma_cr_t send_cr{};
- send_cr.status = URMA_CR_SUCCESS;
- send_cr.user_ctx = current->user_ctx;
- send_cr.flag.bs.s_r = 0;
- if (current->flag.bs.complete_enable) {
- PushCompletion(jetty->jetty_cfg.jfs_cfg.jfc,
- local_state, send_cr);
- }
+ auto complete_send = [&] {
+ if (current->flag.bs.complete_enable) {
+ urma_cr_t send_cr{};
+ send_cr.status = URMA_CR_SUCCESS;
+ send_cr.user_ctx = current->user_ctx;
+ send_cr.flag.bs.s_r = 0;
+ PushCompletion(jetty->jetty_cfg.jfs_cfg.jfc,
+ local_state, send_cr);
+ }
+ };
PendingRecv recv{};
urma_jfc_t* remote_jfc = nullptr;
{
std::unique_lock<std::shared_mutex> lock(g_rw_mutex);
auto remote_it = jetty_id_map.find(current->tjetty->id.id);
if (remote_it == jetty_id_map.end()) {
+ complete_send();
continue;
Review Comment:
When the target Jetty has already disappeared, this branch now publishes a
successful SEND completion even though no payload is delivered. The caller then
reclaims the source buffer and treats the RPC bytes as sent, masking teardown
loss as success. Return a provider error with `bad_wr` set to `current`
instead; the normal failed-write path will release the buffer and fail the
connection.
This issue also appears on line 593 of the same file.
##########
src/brpc/urma/urma_endpoint.cpp:
##########
@@ -770,6 +807,7 @@ ssize_t UrmaEndpoint::CutFromIOBufList(butil::IOBuf** from,
size_t ndata) {
<< ", configured_max_sge=" << GetUrmaMaxSge()
<< ", payload_size=" << this_len
<< " on " << _socket->description();
+ ReportFailure(UrmaFailureReason::SEND_POST);
Review Comment:
A provider can return EAGAIN from `urma_post_jetty_send_wr`, but this path
treats every non-success as `SEND_POST` and quarantines the peer. More
importantly, the payload has already been cut from `from` into `_sbuf`;
`Socket::Write` treats EAGAIN as retryable and then sees the request empty, so
the unsent payload is lost rather than retried. Preserve EAGAIN without
reporting a transport failure, and restore/requeue the cut buffer before
returning it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]