This is an automated email from the ASF dual-hosted git repository.
wangdan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new 848ed89af fix(network): fix heartbeat failure caused by inability to
obtain peer address when receiving UDP data (#2364)
848ed89af is described below
commit 848ed89af3c1ea1ab95c1884e3c6c481832f3fcd
Author: Dan Wang <[email protected]>
AuthorDate: Wed Feb 11 11:15:54 2026 +0800
fix(network): fix heartbeat failure caused by inability to obtain peer
address when receiving UDP data (#2364)
Fix https://github.com/apache/incubator-pegasus/issues/2363.
The root cause is that when starting onebox with `--use_product_config`,
both replica
servers and meta servers use
[src/server/config.ini](https://github.com/apache/incubator-pegasus/blob/a9a11da886bd32d170fc166c08b69210d89d6a52/src/server/config.ini)
instead of
[src/server/config.min.ini](https://github.com/apache/incubator-pegasus/blob/a9a11da886bd32d170fc166c08b69210d89d6a52/src/server/config.min.ini).
As a result, beacons are sent and received over **UDP** instead of **TCP**.
The UDP implementation uses Boost.Asio APIs. If the sender socket does not
call `connect()`,
then calling `remote_endpoint()` on the receiver socket will always fail.
The fix is to remove the logic that calls `remote_endpoint()` on the
receiving side. This logic
was introduced in https://github.com/apache/incubator-pegasus/pull/1658 to
handle cross-network
scenarios (when the address in the message header differs from the actual
socket connection
address, the non-forwarding path corrects it to a recognizable address).
Since UDP is primarily used
for the heartbeat scenario, and `beacon_msg` already contains `from_node`
and `hp_from_node`,
this logic can be removed.
---
src/rpc/asio_net_provider.cpp | 30 ------------------------------
1 file changed, 30 deletions(-)
diff --git a/src/rpc/asio_net_provider.cpp b/src/rpc/asio_net_provider.cpp
index de6cea6d3..8bb69837f 100644
--- a/src/rpc/asio_net_provider.cpp
+++ b/src/rpc/asio_net_provider.cpp
@@ -348,19 +348,6 @@ void asio_udp_provider::do_receive()
return;
}
- // Get the remote endpoint of the socket.
- boost::system::error_code ec;
- auto remote = _socket->remote_endpoint(ec);
- if (ec) {
- LOG_ERROR("failed to get the remote endpoint: {}",
ec.message());
- do_receive();
- return;
- }
-
- auto ip = remote.address().to_v4().to_ulong();
- auto port = remote.port();
- const auto &remote_addr = ::dsn::rpc_address(ip, port);
-
auto hdr_format =
message_parser::get_header_type(_recv_reader._buffer.data());
if (NET_HDR_INVALID == hdr_format) {
LOG_ERROR("{}: asio udp read failed: invalid header type '{}'",
@@ -384,23 +371,6 @@ void asio_udp_provider::do_receive()
return;
}
- if (msg->header->from_address != remote_addr) {
- if (!msg->header->context.u.is_forwarded) {
- msg->header->from_address = remote_addr;
- LOG_DEBUG("{}: message's from_address {} is not equal to
socket's remote_addr "
- "{}, assign it to remote_addr.",
- _address,
- msg->header->from_address,
- remote_addr);
- } else {
- LOG_DEBUG("{}: message's from_address {} is not equal to
socket's remote_addr "
- "{}, but it's forwarded message, ignore it!.",
- _address,
- msg->header->from_address,
- remote_addr);
- }
- }
-
msg->to_address = _address;
msg->to_host_port = _hp;
if (msg->header->context.u.is_request) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]