go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

Issues with RPC registration to Etcd.

Open gif-gif opened this issue 1 month ago • 3 comments

5个节点的 etcd 集群,两个服务器运行同一个rpc服务。运行一段时间后,etcd中的key 变得很多,如下图所示都是同一个key 但是有2w多个。

  1. The error is
Image

Environments :

  • OS: Ubuntu
  • go-zero version 1.8.4
  • goctl version 1.24.1

gif-gif avatar Oct 26 '25 07:10 gif-gif

What's your server code? It seems the server registered many times.

kevwan avatar Oct 26 '25 12:10 kevwan

My gRPC configuration is :

Name: product.gorpc.rpc
ListenOn: 0.0.0.0:3031
Mode: pro
Timeout: 20000

Log:
  Level: info
  Mode: file
  KeepDays: 10

Middlewares:
  Timeout: true

Etcd:
  User: "root"
  Pass: "123!@#QWE"
  Hosts:
    - 191.56.28.210:2230
  Key: productService/GoRpc.rpc

Mysql:
  DataSource: "root:123123@tcp(123.123.123:3603)/product_online?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai"

Prometheus:
  Host: 0.0.0.0
  Port: 3032
  Path: /metrics

After the program runs normally for a period of time, the above issue occurs, and the number of registrations increases over time, feeling like go-zero is continuously repeating the registration.

main.go :

Image

service_context.go:

Image

gif-gif avatar Oct 29 '25 01:10 gif-gif

检查 RPC 服务到 Etcd 的网络稳定性,确保 KeepAlive 正常。确认 Etcd 集群健康度。随后清理 Etcd 中重复的过期 Key。 如果etcd 是集群,最好列出所有节点,增加容错性。

Humphrey-He avatar Oct 29 '25 10:10 Humphrey-He