baidu / braft

An industrial-grade C++ implementation of RAFT consensus algorithm based on brpc, widely used inside Baidu to build highly-available distributed systems.
Apache License 2.0
3.99k stars 886 forks source link

集群启动时,在prevote 时出现 no route to host #372

Closed CountingStarts closed 2 years ago

CountingStarts commented 2 years ago

W0913 15:59:23.734335 498993 /root/braft/src/braft/node.cpp:1525] node kv10:10.42.55.223:8300:0 request PreVote from 10.42.55.222:8300:0 error: [E113]Fail to connect Socket{id=339 addr=10.42.55.222:8300} (0x0x4946000): No route to host

`

for (std::set::const_iterator iter = peers.begin(); iter != peers.end(); ++iter) { if (iter == _server_id) { continue; } brpc::ChannelOptions options; options.connection_type = brpc::CONNECTION_TYPE_SINGLE; options.max_retry = 0; brpc::Channel channel; if (0 != channel.Init(iter->addr, &options)) { LOG(WARNING) << "node " << _group_id << ":" << _server_id << " channel init failed, addr " << iter->addr; continue; } OnPreVoteRPCDone done = new OnPreVoteRPCDone( *iter, _current_term, _pre_vote_ctx.version(), this); done->cntl.set_timeout_ms(_options.election_timeout_ms); done->request.set_group_id(_group_id); done->request.set_server_id(_server_id.to_string()); done->request.set_peer_id(iter->to_string()); done->request.set_term(_current_term + 1); // next term done->request.set_last_log_index(last_log_id.index); done->request.set_last_log_term(last_log_id.term); RaftService_Stub stub(&channel); stub.pre_vote(&done->cntl, &done->request, &done->response, done); }`