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.84k stars 862 forks source link

feat: replace the type of PeerId::addr from butil::EndPoint to string #429

Open gulu-goolu opened 6 months ago

xiaolin310 commented 6 months ago

有个问题咨询下,看起来您这种改动Init channel 时使用的API是,

int Init(const char* server_addr_and_port, const ChannelOptions* options); // www.foo.com:8080

想问下,您测试过failover情况吗,比如一个pod(deployment或者statefulset controller) 被kill -9 (或者delete pod --force, 非graceful shutdown), 这个时候新拉起的pod IP变了。

我之前的测试情况,用这个channel Init API 并不会把hostname解析成新的pod IP,因而新的RPC request根本发不到新的Pod应用。 想知道您那边的测试情况,欢迎交流~

gulu-goolu commented 6 months ago

会有这种问题,要解决这个问题的话,可以试试 channel 的另一个初始化方法。

int Init(const char* service_url, const char* load_balancer, const ChannelOptions*);

然后协议用 dns,比如 dns://host1.default.svc.:1000 这种。具体原理是这个 domain_naming_service.h

这个方案理论上能解决你遇到的这个问题,但是因为我们的项目还比较早期,所以就还没有按照这样修改。

xiaolin310 commented 6 months ago

@gulu-goolu PTAL

https://github.com/baidu/braft/pull/419