smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.11k stars 1.17k forks source link

example/etcdv3_registry 多个server,其中一个server异常退出后,client报错 #144

Closed cookeem closed 7 years ago

cookeem commented 7 years ago

运行rpcx-examples2/etcdv3_registry,我开启了多个server,但是关闭其中一个server之后,client会出现部分任务提交异常,etcd registry不是能够自动发现server down掉,自动从server list中清除吗?为什么client还是继续向down掉得server提交任务?

例如我启动了两个server:

go run rpcx/etcdv3_registry/server.go -s 127.0.0.1:12001 &
go run rpcx/etcdv3_registry/server.go -s 127.0.0.1:12002 &

关掉其中一个server,启动client向服务器提交任务,就会有部分任务 connection refused。

2017/08/11 09:35:30 client.go:44: INFO : Arith: 98*54=5292, took 312.856µs
2017/08/11 09:35:30 client_direct_creator.go:48: ERROR: failed to dial server: dial tcp 127.0.0.1:12002: getsockopt: connection refused
2017/08/11 09:35:30 client.go:42: INFO : error for Arith: 16*90, dial tcp 127.0.0.1:12002: getsockopt: connection refused, took 190.547µs
cookeem commented 7 years ago

我设置的UpdateIntervalInSec是1秒

    rplugin := &plugin.EtcdV3RegisterPlugin{
        ServiceAddress:      "tcp@" + *addr,
        EtcdServers:         []string{*e},
        BasePath:            "/rpcx",
        Metrics:             metrics.NewRegistry(),
        UpdateIntervalInSec: 1,
    }

为什么debug输出TTL是21秒?

2017/08/11 10:58:46 etcdv3_register.go:95: DEBUG: TTL value is 21
2017/08/11 10:58:48 etcdv3_register.go:95: DEBUG: TTL value is 21
smallnest commented 7 years ago

added ExtraTimeInSec for EtcdV3RegisterPlugin which is used to add extra time for TTL