go
config_error
ai_generated
true
rpc error: code = AlreadyExists desc = duplicate registration of service pb.OrderService
ID: go/grpc-already-exists
80%Fix Rate
86%Confidence
0Evidence
2024-04-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| google.golang.org/grpc v1.46+ | active | — | — | — |
Root Cause
RegisterOrderServiceServer was called twice on the same grpc.Server, or two server instances share a registry. gRPC panics on duplicate service registration.
generic中文
在同一个 grpc.Server 上两次调用了 RegisterOrderServiceServer,或两个服务端实例共享了注册表。gRPC 在重复注册服务时会 panic。
Workarounds
-
95% success
s := grpc.NewServer() pb.RegisterOrderServiceServer(s, svc) // do not register again elsewhere
-
85% success
var once sync.Once once.Do(func() { pb.RegisterOrderServiceServer(s, svc) })
Dead Ends
Common approaches that don't work:
-
80% fail
Recovering hides the bug; the second registration still fails and the server state is inconsistent.
-
75% fail
Multiple servers on one listener conflict; only one can bind the port, and requests route unpredictably.