Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2P: Provide better log message when unable to resolve host #523

Closed
wants to merge 1 commit into from

Conversation

heifner
Copy link
Member

@heifner heifner commented Aug 12, 2024

Before:

info  2024-08-12T16:20:02.907 net-1     net_plugin.cpp:2794           operator()           ] connection failed to p2p.spring-beta.jungletestnet.io:9898, Element not found

After

info  2024-08-12T16:24:02.571 net-2     net_plugin.cpp:2795           operator()           ] connection failed to p2p.spring-beta.jungletestnet.io:9898, Unable to resolve endpoint

@heifner heifner added the OCI Work exclusive to OCI team label Aug 12, 2024
@@ -2791,7 +2791,8 @@ namespace eosio {
c->send_time();
}
} else {
fc_ilog( logger, "connection failed to ${a}, ${error}", ("a", c->peer_address())( "error", err.message()));
fc_ilog(logger, "connection failed to ${a}, ${e}", ("a", c->peer_address())
("e", err == boost::asio::error::not_found ? "Unable to resolve endpoint" : err.message()));
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little suspicious this isn't the right location for such a test. If we can't resolve any hosts wouldn't this be the right location for handling such a thing?

resolver->async_resolve(host, port,
[resolver, host = host, port = port, peer_address = peer_address, listen_address = listen_address, this]( const boost::system::error_code& err, const tcp::resolver::results_type& results ) {
connection_ptr c = std::make_shared<connection>( peer_address, listen_address );
c->set_heartbeat_timeout( heartbeat_timeout );
std::lock_guard g( connections_mtx );
auto [it, inserted] = connections.emplace( connection_detail{
.host = peer_address,
.c = std::move(c),
.ips = results
});
if( !err ) {
it->c->connect( results );
} else {
fc_wlog( logger, "Unable to resolve ${host}:${port} ${error}",
("host", host)("port", port)( "error", err.message() ) );
it->c->set_state(connection::connection_state::closed);
++(it->c->consecutive_immediate_connection_close);
}

Is it possible when being unable to resolve any hosts async_resolve completes successfully but returns an empty result list? (that seems at odds with documentation, just trying to think how this existing Unable to resolve path isn't getting hit)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. Seems the issue is that we add the connection to the connections index even if it doesn't resolve. Then we use that .ips for reconnection. Seems instead we should attempt to resolve the host on each new re-connection.

@heifner
Copy link
Member Author

heifner commented Aug 12, 2024

Created a new issue for this: #525. Thanks @spoonincode

@heifner heifner closed this Aug 12, 2024
@ericpassmore
Copy link
Contributor

ericpassmore commented Aug 12, 2024

Note:start
group: LOGGING
category: CLOSED
summary: Improved log message when unable to resolve host.
Note: end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants